(this.dragger = ref)}
150 | onMouseDown={this.handleMouseDown}
151 | />
152 |
153 | );
154 | }
155 | }
156 |
157 | Dragger.propTypes = {
158 | color: PropTypes.string,
159 | left: PropTypes.number,
160 | value: PropTypes.number,
161 | maxDis: PropTypes.number,
162 | min: PropTypes.number,
163 | max: PropTypes.number,
164 | onDragEnd: PropTypes.func,
165 | onDraging: PropTypes.func,
166 | useTipso: PropTypes.bool,
167 | showTipso: PropTypes.bool,
168 | draggerClass: PropTypes.string,
169 | tipsoClass: PropTypes.string,
170 | tipsoTrigger: PropTypes.string,
171 | };
172 |
173 | Dragger.defaultProps = {
174 | left: 0,
175 | value: 0,
176 | maxDis: 0,
177 | min: 0,
178 | max: 0,
179 | color: 'green',
180 | onDragEnd: Function.prototype,
181 | onDraging: Function.prototype,
182 | useTipso: true,
183 | showTipso: false,
184 | draggerClass: '',
185 | tipsoClass: '',
186 | tipsoTrigger: 'hover',
187 | };
188 |
189 | export default Dragger;
190 |
--------------------------------------------------------------------------------
/components/react/Form/SelectorV2/selector.css:
--------------------------------------------------------------------------------
1 | @import '../../../shared/styles/font.css';
2 | @import "../../../shared/styles/shadow.css";
3 | @import "../../../shared/styles/z-index.css";
4 | @import "../../../shared/styles/color.css";
5 | @import "../../../shared/styles/border.css";
6 |
7 | :root {
8 | --speed: .2s;
9 | --easing: cubic-bezier(.55,0,.1,1);
10 | --modalContentOpacity: 0;
11 | --scale: scale(0.8);
12 | --scaleActive: scale(1);
13 | }
14 |
15 | .selectorContainer {
16 | background-color: var(--white);
17 | margin: 10px 5px;
18 | min-width: 4em;
19 | text-align: center;
20 | transition: background-color 0.2s, box-shadow 0.2s;
21 | border-radius: var(--radius-small);
22 | position: relative;
23 | display: inline-block;
24 | composes: baseText;
25 |
26 | color: var(--gray-dark);
27 | fill: var(--gray-dark);
28 |
29 | & .icon polygon {
30 | fill: var(--gray-dark);
31 | }
32 |
33 | & .icon svg {
34 | transition: transform 0.2s, background-color 0.2s;
35 | }
36 |
37 | &::before {
38 | content: '';
39 | display: block;
40 | position: absolute;
41 | top: 0;
42 | right: 0;
43 | bottom: 0;
44 | left: 0;
45 | border-radius: var(--radius-small);
46 | background-color: transparent;
47 | transition: background-color 0.2s;
48 | }
49 |
50 | &:first-child {
51 | margin-left: 0;
52 | }
53 |
54 | &:last-child {
55 | margin-right: 0;
56 | }
57 | }
58 |
59 | .wrapper {
60 | cursor: pointer;
61 | display: flex;
62 | flex-direction: row;
63 | transform: translateY(0);
64 | justify-content: center;
65 | align-items: center;
66 | text-align: left;
67 | padding: 10px 20px;
68 | }
69 |
70 | .valueWrapper {
71 | flex: 1 0 auto;
72 | position: relative;
73 | }
74 |
75 | .valueHidden {
76 | opacity: 0;
77 | visibility: hidden;
78 | pointer-events: none;
79 | }
80 |
81 | .value {
82 | position: absolute;
83 | }
84 |
85 | .material {
86 | border: none;
87 | transition: box-shadow 0.2s;
88 | box-shadow: var(--shadow4);
89 |
90 | &:not(.selectorDisabled) {
91 | &:hover {
92 | box-shadow: var(--shadow6);
93 | }
94 | }
95 |
96 | & .optionsContainer {
97 | box-shadow: var(--shadow6);
98 | }
99 | }
100 |
101 | .flat {
102 | color: var(--gray-dark);
103 | fill: var(--gray-dark);
104 | background-color: var(--white);
105 | transition: border 0.1s;
106 | border: 1px solid var(--gray);
107 |
108 | & .icon polygon {
109 | fill: var(--gray-dark);
110 | }
111 |
112 | & .optionsContainer {
113 | box-shadow: var(--shadowInput);
114 | border: 1px solid var(--gray);
115 | }
116 | }
117 |
118 | .selector-white {
119 | &.material {
120 | background-color: var(--gray-dark);
121 | color: var(--white);
122 | fill: var(--white);
123 |
124 | & .icon polygon {
125 | fill: var(--white);
126 | }
127 | }
128 |
129 | &.flat:not(.selectorDisabled) {
130 | &:hover {
131 | border: 1px solid var(--gray);
132 | }
133 | }
134 | }
135 |
136 | .selector-green {
137 | &.material {
138 | fill: var(--white);
139 | color: var(--white);
140 | background-color: var(--green);
141 |
142 | & .icon polygon {
143 | fill: var(--white);
144 | }
145 | }
146 |
147 | &.flat:not(.selectorDisabled) {
148 | &:hover {
149 | border: 1px solid var(--green);
150 | }
151 | }
152 | }
153 |
154 | .selector-blue {
155 | &.material {
156 | fill: var(--white);
157 | color: var(--white);
158 | background-color: var(--blue);
159 |
160 | & .icon polygon {
161 | fill: var(--white);
162 | }
163 | }
164 |
165 | &.flat:not(.selectorDisabled) {
166 | &:hover {
167 | border: 1px solid var(--blue);
168 | }
169 | }
170 | }
171 |
172 | .selectorDisabled {
173 | cursor: not-allowed;
174 |
175 | & .selector {
176 | cursor: not-allowed;
177 | }
178 |
179 | &::before {
180 | z-index: var(--zIndex1);
181 | background-color: rgba(255, 255, 255, 0.4);
182 | }
183 | }
184 |
185 | .selectorContainerActive {
186 | & .optionsContainer {
187 | z-index: var(--zIndex99);
188 | visibility: visible;
189 | opacity: 1;
190 | transform: var(--scaleActive) translateY(-2px);
191 | }
192 |
193 | & .icon svg {
194 | transform: rotate(180deg);
195 | }
196 | }
197 |
198 | /* options */
199 | .optionsContainer {
200 | position: absolute;
201 | top: calc(100% + 8px);
202 | left: -1px;
203 | right: -1px;
204 | max-height: 400px;
205 | flex-direction: column;
206 | background-color: var(--white);
207 | justify-content: center;
208 | align-items: flex-start;
209 | overflow-y: auto;
210 | border-radius: var(--radius-small);
211 |
212 | z-index: var(--zIndex0);
213 | opacity: var(--modalContentOpacity);
214 | visibility: hidden;
215 | backface-visibility: hidden;
216 | transform: var(--scale) translateY(-2px);
217 | transition: all var(--speed) var(--easing);
218 | }
219 |
220 |
221 | .option {
222 | height: 30px;
223 | width: 100%;
224 | text-align: left;
225 | line-height: 30px;
226 | cursor: pointer;
227 | color: var(--gray-dark);
228 | background-color: transparent;
229 | transition: background-color 0.2s;
230 | display: inline-block;
231 |
232 | &:hover {
233 | background-color: #f2f2f2;
234 | }
235 |
236 | &:first-child {
237 | border-radius: var(--radius-small) var(--radius-small) 0 0;
238 | }
239 |
240 | &:last-child {
241 | border-radius: 0 0 var(--radius-small) var(--radius-small);
242 | }
243 | }
244 |
245 | .optionActive {
246 | cursor: default;
247 | background-color: #f2f2f2;
248 | }
249 |
250 | .optionDisabled {
251 | color: #ADADAD;
252 | cursor: not-allowed;
253 | }
254 |
255 | .optionWrapper {
256 | margin: 0 20px;
257 | }
258 |
259 | .optionHidden {
260 | opacity: 0;
261 | visibility: hidden;
262 | pointer-events: none;
263 | display: inline;
264 | z-index: var(--zIndexHidden);
265 | position: absolute;
266 | top: 0;
267 | left: 0;
268 | width: 100%;
269 | }
270 |
271 | .optionHiddenItem {
272 | opacity: 0;
273 | visibility: hidden;
274 | pointer-events: none;
275 | display: inline;
276 | }
277 |
--------------------------------------------------------------------------------
/examples/DropdownWrapper.jsx:
--------------------------------------------------------------------------------
1 |
2 | import React from 'react';
3 | import cx from 'classnames';
4 | import Dropdown from '../components/react/Dropdown';
5 | import Switcher from '../components/react/Switcher';
6 | import Button from '../components/react/Button/Button';
7 | import IconButton from '../components/react/Button/IconButton';
8 | import FloatingActionButton from '../components/react/Button/FloatingActionButton';
9 | import styles from './shared/styles.css';
10 |
11 | const MENUS = [
12 | { id: 0, value: 'menu 1' },
13 | { id: 1, value: 'menu 2' },
14 | { id: 2, value: 'menu 3' },
15 | { id: 3, value: 'this is long menu this is long menu' },
16 | ];
17 |
18 | class DropdownWrapper extends React.Component {
19 | constructor(props) {
20 | super(props);
21 | this.state = {
22 | activeMenu: MENUS[0].id,
23 | switchers: [
24 | false,
25 | true,
26 | false,
27 | ]
28 | };
29 | this.onSelect = this.onSelect.bind(this);
30 | }
31 |
32 | onSelect(activeMenu) {
33 | this.setState({ activeMenu });
34 | }
35 |
36 | renderMenus(dark) {
37 | const { activeMenu } = this.state;
38 | return MENUS.map((menu, index) => {
39 | return (
40 |
this.onSelect(menu.id)}
43 | className={cx(
44 | styles.menu,
45 | dark && styles['menuDark'],
46 | menu.id === activeMenu && styles.active
47 | )}
48 | >
49 | {menu.value}
50 |
51 | );
52 | });
53 | }
54 |
55 | onSwitch(index) {
56 | return (checked) => {
57 | const { switchers } = this.state;
58 | this.setState({
59 | switchers: [
60 | ...switchers.slice(0, index),
61 | checked,
62 | ...switchers.slice(index + 1)
63 | ]
64 | });
65 | };
66 | }
67 |
68 | renderOperactionMenus() {
69 | const { switchers } = this.state;
70 |
71 | return switchers.map((checked, index) => (
72 |
78 |
84 |
85 | {checked ? 'checked' : 'uncheck'}
86 |
87 | ));
88 | }
89 |
90 | renderDropdownButton() {
91 | return (
92 |
97 | );
98 | }
99 |
100 | render() {
101 | const { value, selected } = this.state;
102 | const { disabled } = this.props;
103 |
104 | return (
105 |
106 |
Dropdown
107 |
108 |
120 | )}
121 | menuPanelClassName={styles.menuPanel}
122 | buttonClassName={styles.dropdownTrigger}
123 | />
124 |
125 |
126 |
127 |
139 | )}
140 | menuPanelClassName={styles['menuPanel-2']}
141 | buttonClassName={styles.dropdownTrigger}
142 | />
143 |
144 |
145 |
146 |
159 | )}
160 | menuPanelClassName={styles['menuPanel-2-dark']}
161 | buttonClassName={styles.dropdownTrigger}
162 | />
163 |
164 |
165 |
166 |
179 | )}
180 | menuPanelClassName={styles.menuPanel}
181 | buttonClassName={styles.dropdownTrigger}
182 | />
183 |
184 |
185 |
186 |
199 | )}
200 | menuPanelClassName={styles.menuPanel}
201 | buttonClassName={styles.dropdownTrigger}
202 | />
203 |
204 |
205 | );
206 | }
207 | }
208 |
209 | export default DropdownWrapper;
210 |
--------------------------------------------------------------------------------
/components/react/Form/SelectorV2/index.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import cx from 'classnames';
3 | import PropTypes from 'prop-types';
4 |
5 | import Option from './Option';
6 | import styles from './selector.css';
7 | import icons from '../../../shared/utils/icons';
8 | import helper from '../../../shared/utils/helper';
9 | import OutsideClickHandler from '../../../shared/components/OutsideClickHandler';
10 |
11 | class SelectorV2 extends React.Component {
12 | constructor(props) {
13 | super(props);
14 | this.state = {
15 | active: false
16 | };
17 | this.onChange = this.onChange.bind(this);
18 | this.handleOutsideClick = this.handleOutsideClick.bind(this);
19 | this.handleActiveChange = this.handleActiveChange.bind(this);
20 | this.handleActiveToggle = this.handleActiveToggle.bind(this);
21 | }
22 |
23 | onChange(val) {
24 | const { onChange } = this.props;
25 | onChange && onChange(val);
26 | this.handleOutsideClick();
27 | }
28 |
29 | handleOutsideClick() {
30 | this.handleActiveChange(false);
31 | const { onSelectorClose } = this.props;
32 | onSelectorClose && onSelectorClose();
33 | }
34 |
35 | handleActiveChange(active) {
36 | this.setState({ active });
37 | }
38 |
39 | handleActiveToggle() {
40 | const { active } = this.state;
41 | this.handleActiveChange(!active);
42 | }
43 |
44 | renderOptions() {
45 | const {
46 | value,
47 | options,
48 | optionClassName,
49 | optionModalClassName
50 | } = this.props;
51 | const optionComponents = options.map((option, index) => {
52 | const { id, hidden } = option;
53 | if (hidden) return null;
54 | return (
55 |
64 | );
65 | });
66 |
67 | return (
68 |
75 | {optionComponents}
76 |
77 | );
78 | }
79 |
80 | get maxLengthValue() {
81 | const { options } = this.props;
82 | let maxValue = (options[0] && options[0].text) || '';
83 | options.forEach((option) => {
84 | if (helper.getStringWidth(option.value) > helper.getStringWidth(maxValue)) { maxValue = option.value; }
85 | });
86 | return maxValue;
87 | }
88 |
89 | renderSelected() {
90 | const {
91 | value,
92 | options,
93 | flexable,
94 | selectedClassName,
95 | } = this.props;
96 |
97 | const targetOptions = options.filter(option => option.id === value);
98 | const targetValue = (targetOptions[0] && targetOptions[0].value) || '';
99 |
100 | if (!flexable) {
101 | const maxLengthValue = this.maxLengthValue;
102 | return (
103 |
104 | {targetValue}
105 | {maxLengthValue}
106 |
107 | );
108 | }
109 |
110 | return (
111 |
112 | {targetValue}
113 |
114 | );
115 | }
116 |
117 | get selectorWidth() {
118 | const { optionClassName } = this.props;
119 | const tmpClassName = cx(styles.option, optionClassName, styles.optionHidden);
120 | const maxLengthValue = this.maxLengthValue;
121 |
122 | const tmpNode = document.createElement('div');
123 | tmpNode.setAttribute('class', tmpClassName);
124 | const hiddenDOM = document.createElement('div');
125 | hiddenDOM.setAttribute('class', cx(styles.optionWrapper, styles.optionHiddenItem));
126 | hiddenDOM.appendChild(document.createTextNode(maxLengthValue));
127 | tmpNode.appendChild(hiddenDOM);
128 |
129 | document.body.appendChild(tmpNode);
130 | const width = hiddenDOM.offsetWidth + 40;
131 | tmpNode.remove();
132 | return width;
133 | }
134 |
135 | render() {
136 | const { active } = this.state;
137 | const {
138 | theme,
139 | color,
140 | disabled,
141 | showArrow,
142 | className,
143 | } = this.props;
144 |
145 | const containerClass = cx(
146 | styles.selectorContainer,
147 | styles[`selector-${color}`],
148 | styles[theme],
149 | active && styles.selectorContainerActive,
150 | disabled && styles.selectorDisabled,
151 | className
152 | );
153 |
154 | const onClick = disabled ? Function.prototype : () => this.handleActiveToggle();
155 |
156 | return (
157 |
158 |
159 |
160 | {this.renderSelected()}
161 | {showArrow && (
162 |
163 |
164 | {icons.down}
165 |
166 | )}
167 |
168 | {this.renderOptions()}
169 |
170 |
171 | );
172 | }
173 | }
174 |
175 | SelectorV2.propTypes = {
176 | options: PropTypes.array,
177 | value: PropTypes.oneOfType([
178 | PropTypes.bool,
179 | PropTypes.string,
180 | PropTypes.number,
181 | ]),
182 | onChange: PropTypes.func,
183 | onSelectorClose: PropTypes.func,
184 | theme: PropTypes.string,
185 | color: PropTypes.string,
186 | className: PropTypes.string,
187 | disabled: PropTypes.bool,
188 | showArrow: PropTypes.bool,
189 | flexable: PropTypes.bool,
190 | optionClassName: PropTypes.string,
191 | selectedClassName: PropTypes.string,
192 | optionModalClassName: PropTypes.string,
193 | };
194 |
195 | SelectorV2.defaultProps = {
196 | options: [],
197 | onChange: Function.prototype,
198 | onSelectorClose: Function.prototype,
199 | theme: 'material',
200 | color: 'green',
201 | className: '',
202 | disabled: false,
203 | showArrow: true,
204 | flexable: false,
205 | optionClassName: '',
206 | selectedClassName: '',
207 | optionModalClassName: '',
208 | };
209 |
210 | export default SelectorV2;
211 |
--------------------------------------------------------------------------------
/examples/CardWrapper.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import InfoCard from '../components/react/Card/InfoCard'
3 | import ClassicCard from '../components/react/Card/ClassicCard'
4 | import CardGroup from '../components/react/Card/CardGroup'
5 | import styles from './shared/styles.css';
6 |
7 | class CardWrapper extends React.Component {
8 | render() {
9 | return (
10 |
11 |
Min Info Card
12 |
13 |
17 |
22 |
27 |
28 |
35 |
36 |
37 |
44 |
45 |
46 |
47 |
52 |
58 |
64 |
65 |
66 |
72 |
79 |
80 |
Min Info Card with Tipso
81 |
82 |
90 |
99 |
100 |
Inject custom node on card
101 |
102 |
108 |
109 |
110 | )}
111 | />
112 |
113 |
Card Group
114 |
115 |
116 |
124 |
129 |
130 |
131 |
132 |
133 |
134 |
142 |
147 |
152 |
153 |
154 |
162 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
181 |
186 |
191 |
192 |
193 |
201 |
206 |
207 |
208 |
209 |
210 | );
211 | }
212 | }
213 |
214 | export default CardWrapper;
215 |
--------------------------------------------------------------------------------
/components/react/Button/BaseButton/button.css:
--------------------------------------------------------------------------------
1 | @import "../../../shared/styles/shadow.css";
2 | @import "../../../shared/styles/z-index.css";
3 | @import '../../../shared/styles/color.css';
4 | @import '../../../shared/styles/border.css';
5 | @import '../../../shared/styles/font.css';
6 |
7 | :root {
8 | --background-transition : background-color 0.2s;
9 | --color-transition : color 0.2s;
10 | }
11 |
12 | .button {
13 | text-align: center;
14 | cursor: default;
15 | padding: 10px 20px;
16 | border-radius: var(--radius-small);
17 | margin: 15px 5px;
18 | display: inline-flex;
19 | justify-content: center;
20 | align-items: center;
21 | flex-direction: row;
22 | user-select: none;
23 | position: relative;
24 | composes: baseSubText;
25 |
26 | & .wrapper {
27 | transform: translateY(0);
28 | }
29 |
30 | &.clickable:not(.disabled) {
31 | &:hover {
32 | &::before {
33 | background-color: var(--black);
34 | }
35 | }
36 | }
37 |
38 | &.clickable {
39 | cursor: pointer;
40 | }
41 |
42 | & i:first-child {
43 | margin-right: 10px;
44 | }
45 |
46 | & i:last-child {
47 | margin-left: 10px;
48 | }
49 |
50 | &:first-child {
51 | &:not(.floating-action-button) {
52 | margin-left: 0;
53 | }
54 | }
55 |
56 | &:last-child {
57 | &:not(.floating-action-button) {
58 | margin-right: 0;
59 | }
60 | }
61 |
62 | &::before {
63 | content: '';
64 | display: block;
65 | position: absolute;
66 | top: 0;
67 | right: 0;
68 | bottom: 0;
69 | left: 0;
70 | margin: -1px;
71 | opacity: 0.3;
72 | border-radius: var(--radius-small);
73 | background-color: transparent;
74 | transition: var(--background-transition);
75 | }
76 | }
77 |
78 | .flat {
79 | transition: var(--background-transition), var(--color-transition);
80 |
81 | &.white {
82 | border: none;
83 | color: var(--gray-dark);
84 | background-color: var(--white);
85 |
86 | & i {
87 | color: var(--gray-dark);
88 | }
89 | }
90 |
91 | &.green {
92 | border: 1px solid var(--green-dark);
93 | color: var(--green-dark);
94 |
95 | & i {
96 | color: var(--green-dark);
97 | }
98 |
99 | &.active,
100 | &.clickable:not(.disabled):hover {
101 | background-color: var(--green-dark);
102 | color: var(--white);
103 |
104 | & i {
105 | color: var(--white);
106 | }
107 | }
108 | }
109 |
110 | &.red {
111 | border: 1px solid var(--red-dark);
112 | color: var(--red-dark);
113 |
114 | & i {
115 | color: var(--red-dark);
116 | }
117 |
118 | &.active,
119 | &.clickable:not(.disabled):hover {
120 | background-color: var(--red-dark);
121 | color: var(--white);
122 |
123 | & i {
124 | color: var(--white);
125 | }
126 | }
127 | }
128 |
129 | &.blue {
130 | border: 1px solid var(--blue-dark);
131 | color: var(--blue-dark);
132 |
133 | & i {
134 | color: var(--blue-dark);
135 | }
136 |
137 | &.active,
138 | &.clickable:not(.disabled):hover {
139 | background-color: var(--blue-dark);
140 | color: var(--white);
141 |
142 | & i {
143 | color: var(--white);
144 | }
145 | }
146 | }
147 |
148 | &.dark {
149 | border: 1px solid var(--gray-dark);
150 | color: var(--gray-dark);
151 |
152 | & i {
153 | color: var(--gray-dark);
154 | }
155 |
156 | &.active,
157 | &.clickable:not(.disabled):hover {
158 | background-color: var(--gray-dark);
159 | color: var(--white);
160 |
161 | & i {
162 | color: var(--white);
163 | }
164 | }
165 | }
166 |
167 | &.gray {
168 | border: 1px solid var(--gray);
169 | color: var(--gray);
170 |
171 | & i {
172 | color: var(--gray);
173 | }
174 |
175 | &.active,
176 | &.clickable:not(.disabled):hover {
177 | background-color: var(--gray);
178 | color: var(--white);
179 |
180 | & i {
181 | color: var(--white);
182 | }
183 | }
184 | }
185 | }
186 |
187 | .material {
188 | color: var(--white);
189 | border: 1px solid transparent;
190 | box-shadow: var(--shadow4);
191 | transition: box-shadow 200ms cubic-bezier(0.165, 0.84, 0.44, 1);
192 |
193 | &.active,
194 | &.clickable:not(.disabled):hover {
195 | box-shadow: var(--shadow6);
196 | }
197 |
198 | &.white {
199 | color: var(--gray-dark);
200 | background-color: var(--white);
201 | }
202 |
203 | &.green {
204 | background-color: var(--green-dark);
205 | }
206 |
207 | &.red {
208 | background-color: var(--red-dark);
209 | }
210 |
211 | &.dark {
212 | background-color: var(--gray-dark);
213 | }
214 |
215 | &.gray {
216 | background-color: var(--gray);
217 | }
218 |
219 | &.blue {
220 | background-color: var(--blue-dark);
221 | }
222 | }
223 |
224 | .floating-action-button {
225 | padding: 0;
226 | border-radius: var(--radius-half);
227 | color: var(--white);
228 | box-shadow: var(--shadow5);
229 | transition: box-shadow 200ms cubic-bezier(0.165, 0.84, 0.44, 1);
230 |
231 | &::before {
232 | border-radius: var(--radius-half);
233 | }
234 |
235 | &.white {
236 | color: var(--gray-dark);
237 | background-color: var(--white);
238 | }
239 |
240 | &.green {
241 | background-color: var(--green-dark);
242 | }
243 |
244 | &.red {
245 | background-color: var(--red-dark);
246 | }
247 |
248 | &.dark {
249 | background-color: var(--gray-dark);
250 | }
251 |
252 | &.gray {
253 | background-color: var(--gray);
254 | }
255 |
256 | &.blue {
257 | background-color: var(--blue-dark);
258 | }
259 | }
260 |
261 | .clickable.pressDown {
262 | &.material.material {
263 | box-shadow: var(--shadow2);
264 | }
265 |
266 | &.floating-action-button.floating-action-button {
267 | box-shadow: var(--shadow2);
268 | }
269 |
270 | & .wrapper {
271 | transform: translateY(1px);
272 | }
273 | }
274 |
275 | .disabled {
276 | cursor: not-allowed !important;
277 |
278 | &::before {
279 | z-index: var(--zIndex1);
280 | background-color: var(--gray);
281 | }
282 | }
283 |
284 | .ghost {
285 | color: var(--gray-dark);
286 | border: 1px solid transparent;
287 | transition: var(--background-transition), var(--color-transition);
288 |
289 | &.active,
290 | &.clickable:not(.disabled):hover {
291 | color: var(--white);
292 |
293 | & i {
294 | color: var(--white);
295 | }
296 |
297 | &.green {
298 | background-color: var(--green);
299 | }
300 |
301 | &.red {
302 | background-color: var(--red);
303 | }
304 |
305 | &.dark {
306 | background-color: var(--gray-dark);
307 | }
308 |
309 | &.white {
310 | background-color: var(--gray-dark);
311 | }
312 |
313 | &.gray {
314 | background-color: var(--gray);
315 | }
316 |
317 | &.blue {
318 | background-color: var(--blue);
319 | }
320 | }
321 |
322 | &.green {
323 | color: var(--green-dark);
324 | }
325 |
326 | &.red {
327 | color: var(--red-dark);
328 | }
329 |
330 | &.dark {
331 | color: var(--gray-dark);
332 | }
333 |
334 | &.white {
335 | color: var(--gray-dark);
336 | }
337 |
338 | &.gray {
339 | color: var(--gray);
340 | }
341 |
342 | &.blue {
343 | color: var(--blue-dark);
344 | }
345 | }
346 |
347 | .label {
348 | & i:first-child {
349 | margin-right: 5px;
350 | }
351 | }
352 |
--------------------------------------------------------------------------------
/components/react/Switcher/switcher.css:
--------------------------------------------------------------------------------
1 | @import "../../shared/styles/shadow.css";
2 | @import "../../shared/styles/z-index.css";
3 | @import "../../shared/styles/color.css";
4 | @import "../../shared/styles/border.css";
5 |
6 | :root {
7 | /* version 1 */
8 | --v1-switcher-width: 52px;
9 | --v1-switcher-width-small: 42px;
10 | --v1-switcher-width-mini: 35px;
11 |
12 | --v1-switcher: 32px;
13 | --v1-switcher-small: 26px;
14 | --v1-switcher-mini: 22px;
15 |
16 | --v1-switcher-item: 32px;
17 | --v1-switcher-item-small: 26px;
18 | --v1-switcher-item-mini: 22px;
19 |
20 | /* version 2 */
21 | --v2-switcher-width: 50px;
22 | --v2-switcher-width-small: 40px;
23 | --v2-switcher-width-mini: 40px;
24 |
25 | --v2-switcher: 25px;
26 | --v2-switcher-small: 22px;
27 | --v2-switcher-mini: 22px;
28 |
29 | --v2-switcher-item: 17px;
30 | --v2-switcher-item-small: 15px;
31 | --v2-switcher-item-mini: 15px;
32 |
33 | /* version 3 */
34 | --v3-switcher-width: 35px;
35 | --v3-switcher-width-small: 30px;
36 | --v3-switcher-width-mini: 30px;
37 |
38 | --v3-switcher: 4px;
39 | --v3-switcher-small: 3px;
40 | --v3-switcher-mini: 3px;
41 |
42 | --v3-switcher-item: 25px;
43 | --v3-switcher-item-small: 20px;
44 | --v3-switcher-item-mini: 20px;
45 | }
46 |
47 | .switcherContainer {
48 | display: inline-block;
49 | position: relative;
50 | cursor: pointer;
51 | border: 1px solid var(--gray);
52 | transition: background-color 0.2s;
53 | background-color: var(--white);
54 | margin: 15px 5px;
55 |
56 | &:first-child {
57 | margin-left: 0;
58 | }
59 |
60 | &:last-child {
61 | margin-right: 0;
62 | }
63 | }
64 |
65 | .containerChecked {
66 | border: 1px solid transparent;
67 |
68 | &.green {
69 | background-color: var(--green-dark);
70 | }
71 |
72 | &.blue {
73 | background-color: var(--blue-dark);
74 | }
75 |
76 | &.gray {
77 | background-color: var(--gray-dark);
78 | }
79 | }
80 |
81 | .containerDisabled {
82 | cursor: not-allowed !important;
83 |
84 | &::before {
85 | content: '';
86 | display: block;
87 | position: absolute;
88 | top: 0;
89 | right: 0;
90 | bottom: 0;
91 | left: 0;
92 | border-radius: var(--radius-small);
93 | z-index: var(--zIndex1);
94 | background-color: rgba(255, 255, 255, 0.4);
95 | }
96 | }
97 |
98 | .switcherItem {
99 | background-color: var(--white);
100 | box-shadow: var(--shadow2);
101 | box-shadow: 0 1px 3px rgba(0,0,0,.4);
102 | position: absolute;
103 | transition: right 0.2s;
104 | }
105 |
106 | /* switcher v1 */
107 | .switcher-v1 {
108 | &.containerChecked {
109 | & .switcherItem {
110 | right: 0 !important;
111 | }
112 | }
113 |
114 | &.switcherContainer {
115 | width: var(--v1-switcher-width);
116 | height: var(--v1-switcher);
117 | border-radius: var(--v1-switcher);
118 | }
119 |
120 | &.container-small {
121 | width: var(--v1-switcher-width-small);
122 | height: var(--v1-switcher-small);
123 | border-radius: var(--v1-switcher-small);
124 |
125 | & .switcherItem {
126 | width: var(--v1-switcher-item-small);
127 | height: var(--v1-switcher-item-small);
128 | right: calc(100% - var(--v1-switcher-item-small));
129 | }
130 | }
131 |
132 | &.container-mini {
133 | width: var(--v1-switcher-width-mini);
134 | height: var(--v1-switcher-mini);
135 | border-radius: var(--v1-switcher-mini);
136 |
137 | & .switcherItem {
138 | width: var(--v1-switcher-item-mini);
139 | height: var(--v1-switcher-item-mini);
140 | right: calc(100% - var(--v1-switcher-item-mini));
141 | }
142 | }
143 |
144 | & .switcherItem {
145 | top: 0;
146 | width: var(--v1-switcher-item);
147 | height: var(--v1-switcher-item);
148 | border-radius: var(--v1-switcher-item);
149 | right: calc(100% - var(--v1-switcher-item));
150 | }
151 | }
152 |
153 | .switcher-v2 {
154 | &.switcherContainer {
155 | width: var(--v2-switcher-width);
156 | height: var(--v2-switcher);
157 | border-radius: var(--v2-switcher);
158 |
159 | &.containerChecked {
160 | & .switcherItem {
161 | right: calc((var(--v2-switcher) - var(--v2-switcher-item)) / 2) !important;
162 | }
163 | }
164 | }
165 |
166 | &.container-small {
167 | width: var(--v2-switcher-width-small);
168 | height: var(--v2-switcher-small);
169 | border-radius: var(--v2-switcher-small);
170 |
171 | &.containerChecked {
172 | & .switcherItem {
173 | right: calc((var(--v2-switcher-small) - var(--v2-switcher-item-small)) / 2) !important;
174 | }
175 | }
176 |
177 | & .switcherItem {
178 | width: var(--v2-switcher-item-small);
179 | height: var(--v2-switcher-item-small);
180 | top: calc((var(--v2-switcher-small) - var(--v2-switcher-item-small)) / 2);
181 | right: calc(100% - var(--v2-switcher-item-small) - (var(--v2-switcher-small) - var(--v2-switcher-item-small)) / 2);
182 | }
183 | }
184 |
185 | &.container-mini {
186 | width: var(--v2-switcher-width-mini);
187 | height: var(--v2-switcher-mini);
188 | border-radius: var(--v2-switcher-mini);
189 |
190 | &.containerChecked {
191 | & .switcherItem {
192 | right: calc((var(--v2-switcher-mini) - var(--v2-switcher-item-mini)) / 2) !important;
193 | }
194 | }
195 |
196 | & .switcherItem {
197 | width: var(--v2-switcher-item-mini);
198 | height: var(--v2-switcher-item-mini);
199 | top: calc((var(--v2-switcher-mini) - var(--v2-switcher-item-mini)) / 2);
200 | right: calc(100% - var(--v2-switcher-item-mini) - (var(--v2-switcher-mini) - var(--v2-switcher-item-mini)) / 2);
201 | }
202 | }
203 |
204 | & .switcherItem {
205 | width: var(--v2-switcher-item);
206 | height: var(--v2-switcher-item);
207 | border-radius: var(--v2-switcher-item);
208 | right: calc(100% - var(--v2-switcher-item) - (var(--v2-switcher) - var(--v2-switcher-item)) / 2);
209 | top: calc((var(--v2-switcher) - var(--v2-switcher-item)) / 2);
210 | }
211 | }
212 |
213 | .switcher-v3 {
214 | &.switcherContainer {
215 | width: var(--v3-switcher-width);
216 | height: var(--v3-switcher);
217 | border-radius: var(--v3-switcher);
218 |
219 | &:not(.containerChecked) {
220 | background-color: var(--gray);
221 | }
222 |
223 | &.containerChecked {
224 | & .switcherItem {
225 | right: calc((var(--v3-switcher) - var(--v3-switcher-item)) / 2) !important;
226 | }
227 | }
228 | }
229 |
230 | &.container-small {
231 | width: var(--v3-switcher-width-small);
232 | height: var(--v3-switcher-small);
233 | border-radius: var(--v3-switcher-small);
234 |
235 | &.containerChecked {
236 | & .switcherItem {
237 | right: calc((var(--v3-switcher-small) - var(--v3-switcher-item-small)) / 2) !important;
238 | }
239 | }
240 |
241 | & .switcherItem {
242 | width: var(--v3-switcher-item-small);
243 | height: var(--v3-switcher-item-small);
244 | top: calc((var(--v3-switcher-small) - var(--v3-switcher-item-small)) / 2);
245 | right: calc(100% - var(--v3-switcher-item-small) - (var(--v3-switcher-small) - var(--v3-switcher-item-small)) / 2);
246 | }
247 | }
248 |
249 | &.container-mini {
250 | width: var(--v3-switcher-width-mini);
251 | height: var(--v3-switcher-mini);
252 | border-radius: var(--v3-switcher-mini);
253 |
254 | &.containerChecked {
255 | & .switcherItem {
256 | right: calc((var(--v3-switcher-mini) - var(--v3-switcher-item-mini)) / 2) !important;
257 | }
258 | }
259 |
260 | & .switcherItem {
261 | width: var(--v3-switcher-item-mini);
262 | height: var(--v3-switcher-item-mini);
263 | top: calc((var(--v3-switcher-mini) - var(--v3-switcher-item-mini)) / 2);
264 | right: calc(100% - var(--v3-switcher-item-mini) - (var(--v3-switcher-mini) - var(--v3-switcher-item-mini)) / 2);
265 | }
266 | }
267 |
268 | & .switcherItem {
269 | width: var(--v3-switcher-item);
270 | height: var(--v3-switcher-item);
271 | border-radius: var(--v3-switcher-item);
272 | right: calc(100% - var(--v3-switcher-item) - (var(--v3-switcher) - var(--v3-switcher-item)) / 2);
273 | top: calc((var(--v3-switcher) - var(--v3-switcher-item)) / 2);
274 | }
275 | }
276 |
--------------------------------------------------------------------------------
/examples/TipsoWrapper.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import Button from '../components/react/Button/Button';
3 | import Tipso from '../components/react/Tipso/Tipso';
4 | import styles from './shared/styles.css';
5 |
6 | class TipsoWrapper extends React.Component {
7 | render() {
8 | return (
9 |