.circleci
.dependabot
.github
app
chewy
controllers
helpers
javascript
fonts
images
mastodon
actions
components
__tests__
account.js
animated_number.js
attachment_list.js
autosuggest_emoji.js
autosuggest_hashtag.js
autosuggest_input.js
autosuggest_textarea.js
avatar.js
avatar_composite.js
avatar_overlay.js
button.js
column.js
column_back_button.js
column_back_button_slim.js
column_header.js
display_name.js
domain.js
dropdown_menu.js
error_boundary.js
gifv.js
hashtag.js
icon.js
icon_button.js
icon_with_badge.js
intersection_observer_article.js
load_gap.js
load_more.js
load_pending.js
loading_indicator.js
media_gallery.js
missing_indicator.js
modal_root.js
permalink.js
poll.js
radio_button.js
regeneration_indicator.js
relative_timestamp.js
scrollable_list.js
setting_text.js
status.js
status_action_bar.js
status_content.js
status_list.js
containers
features
locales
middleware
reducers
selectors
service_worker
storage
store
utils
api.js
base_polyfills.js
common.js
compare_id.js
extra_polyfills.js
initial_state.js
is_mobile.js
load_keyboard_extensions.js
load_polyfills.js
main.js
performance.js
ready.js
rtl.js
scroll.js
settings.js
stream.js
test_setup.js
uuid.js
packs
styles
lib
mailers
models
policies
presenters
serializers
services
validators
views
workers
bin
config
db
dist
lib
log
nanobox
public
spec
streaming
vendor
.buildpacks
.codeclimate.yml
.dockerignore
.editorconfig
.env.nanobox
.env.production.sample
.env.test
.env.vagrant
.eslintignore
.eslintrc.js
.foreman
.gitattributes
.gitignore
.haml-lint.yml
.nanoignore
.nvmrc
.profile
.rspec
.rubocop.yml
.ruby-version
.sass-lint.yml
.slugignore
.yarnclean
AUTHORS.md
Aptfile
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Capfile
Dockerfile
Gemfile
Gemfile.lock
LICENSE
Procfile
Procfile.dev
README.md
Rakefile
Vagrantfile
app.json
babel.config.js
boxfile.yml
config.ru
crowdin.yml
docker-compose.yml
package.json
postcss.config.js
priv-config
scalingo.json
yarn.lock
66 lines
1.3 KiB
JavaScript
66 lines
1.3 KiB
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import classNames from 'classnames';
|
|
|
|
export default class Button extends React.PureComponent {
|
|
|
|
static propTypes = {
|
|
text: PropTypes.node,
|
|
onClick: PropTypes.func,
|
|
disabled: PropTypes.bool,
|
|
block: PropTypes.bool,
|
|
secondary: PropTypes.bool,
|
|
size: PropTypes.number,
|
|
className: PropTypes.string,
|
|
title: PropTypes.string,
|
|
style: PropTypes.object,
|
|
children: PropTypes.node,
|
|
};
|
|
|
|
static defaultProps = {
|
|
size: 36,
|
|
};
|
|
|
|
handleClick = (e) => {
|
|
if (!this.props.disabled) {
|
|
this.props.onClick(e);
|
|
}
|
|
}
|
|
|
|
setRef = (c) => {
|
|
this.node = c;
|
|
}
|
|
|
|
focus() {
|
|
this.node.focus();
|
|
}
|
|
|
|
render () {
|
|
const style = {
|
|
padding: `0 ${this.props.size / 2.25}px`,
|
|
height: `${this.props.size}px`,
|
|
lineHeight: `${this.props.size}px`,
|
|
...this.props.style,
|
|
};
|
|
|
|
const className = classNames('button', this.props.className, {
|
|
'button-secondary': this.props.secondary,
|
|
'button--block': this.props.block,
|
|
});
|
|
|
|
return (
|
|
<button
|
|
className={className}
|
|
disabled={this.props.disabled}
|
|
onClick={this.handleClick}
|
|
ref={this.setRef}
|
|
style={style}
|
|
title={this.props.title}
|
|
>
|
|
{this.props.text || this.props.children}
|
|
</button>
|
|
);
|
|
}
|
|
|
|
}
|