aboutsummaryrefslogtreecommitdiff
path: root/src/settings/components/ui
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2018-05-01 13:51:07 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2018-05-01 13:51:07 +0900
commit4d7c24f38a6861e1d498b6e7dd5c7be2d1a0ad15 (patch)
tree0948f730a25eeda127c56a0f01009f14d066e4dc /src/settings/components/ui
parent177940981ed9c4f096ad7db20f0b7ee044fd7b17 (diff)
parentfb8a0f36aa4d070df936cc7598ef8dd988ee1b15 (diff)
Merge remote-tracking branch 'origin/master' into background-adjacent-tabs
Diffstat (limited to 'src/settings/components/ui')
-rw-r--r--src/settings/components/ui/add-button.jsx12
-rw-r--r--src/settings/components/ui/add-button.scss13
-rw-r--r--src/settings/components/ui/delete-button.jsx12
-rw-r--r--src/settings/components/ui/delete-button.scss13
-rw-r--r--src/settings/components/ui/input.jsx52
-rw-r--r--src/settings/components/ui/input.scss29
6 files changed, 131 insertions, 0 deletions
diff --git a/src/settings/components/ui/add-button.jsx b/src/settings/components/ui/add-button.jsx
new file mode 100644
index 0000000..79292d8
--- /dev/null
+++ b/src/settings/components/ui/add-button.jsx
@@ -0,0 +1,12 @@
+import './add-button.scss';
+import { h, Component } from 'preact';
+
+class AddButton extends Component {
+ render() {
+ return <input
+ className='ui-add-button' type='button' value='&#x271a;'
+ {...this.props} />;
+ }
+}
+
+export default AddButton;
diff --git a/src/settings/components/ui/add-button.scss b/src/settings/components/ui/add-button.scss
new file mode 100644
index 0000000..beb5688
--- /dev/null
+++ b/src/settings/components/ui/add-button.scss
@@ -0,0 +1,13 @@
+.ui-add-button {
+ border: none;
+ padding: 4;
+ display: inline;
+ background: none;
+ font-weight: bold;
+ color: green;
+ cursor: pointer;
+
+ &:hover {
+ color: darkgreen;
+ }
+}
diff --git a/src/settings/components/ui/delete-button.jsx b/src/settings/components/ui/delete-button.jsx
new file mode 100644
index 0000000..8077a76
--- /dev/null
+++ b/src/settings/components/ui/delete-button.jsx
@@ -0,0 +1,12 @@
+import './delete-button.scss';
+import { h, Component } from 'preact';
+
+class DeleteButton extends Component {
+ render() {
+ return <input
+ className='ui-delete-button' type='button' value='&#x2716;'
+ {...this.props} />;
+ }
+}
+
+export default DeleteButton;
diff --git a/src/settings/components/ui/delete-button.scss b/src/settings/components/ui/delete-button.scss
new file mode 100644
index 0000000..5932a72
--- /dev/null
+++ b/src/settings/components/ui/delete-button.scss
@@ -0,0 +1,13 @@
+
+.ui-delete-button {
+ border: none;
+ padding: 4;
+ display: inline;
+ background: none;
+ color: red;
+ cursor: pointer;
+
+ &:hover {
+ color: darkred;
+ }
+}
diff --git a/src/settings/components/ui/input.jsx b/src/settings/components/ui/input.jsx
new file mode 100644
index 0000000..e99dbc7
--- /dev/null
+++ b/src/settings/components/ui/input.jsx
@@ -0,0 +1,52 @@
+import { h, Component } from 'preact';
+import './input.scss';
+
+class Input extends Component {
+
+ renderText(props) {
+ let inputClassName = props.error ? 'input-error' : '';
+ return <div className='settings-ui-input'>
+ <label htmlFor={props.id}>{ props.label }</label>
+ <input type='text' className={inputClassName} {...props} />
+ </div>;
+ }
+
+ renderRadio(props) {
+ let inputClassName = props.error ? 'input-error' : '';
+ return <div className='settings-ui-input'>
+ <label>
+ <input type='radio' className={inputClassName} {...props} />
+ { props.label }
+ </label>
+ </div>;
+ }
+
+ renderTextArea(props) {
+ let inputClassName = props.error ? 'input-error' : '';
+ return <div className='settings-ui-input'>
+ <label
+ htmlFor={props.id}
+ >{ props.label }</label>
+ <textarea className={inputClassName} {...props} />
+ <p className='settings-ui-input-error'>{ this.props.error }</p>
+ </div>;
+ }
+
+ render() {
+ let { type } = this.props;
+
+ switch (this.props.type) {
+ case 'text':
+ return this.renderText(this.props);
+ case 'radio':
+ return this.renderRadio(this.props);
+ case 'textarea':
+ return this.renderTextArea(this.props);
+ default:
+ console.warn(`Unsupported input type ${type}`);
+ }
+ return null;
+ }
+}
+
+export default Input;
diff --git a/src/settings/components/ui/input.scss b/src/settings/components/ui/input.scss
new file mode 100644
index 0000000..ad4daf8
--- /dev/null
+++ b/src/settings/components/ui/input.scss
@@ -0,0 +1,29 @@
+.settings-ui-input {
+ page-break-inside: avoid;
+
+ * {
+ page-break-inside: avoid;
+ }
+
+ label {
+ font-weight: bold;
+ min-width: 14rem;
+ display: inline-block;
+ }
+
+ input[type='text'] {
+ padding: 4px;
+ width: 8rem;
+ }
+
+ input.input-crror,
+ textarea.input-error {
+ box-shadow: 0 0 2px red;
+ }
+
+ &-error {
+ font-weight: bold;
+ color: red;
+ min-height: 1.5em;
+ }
+}