diff --git a/.babelrc b/.babelrc index 0a68b08..f93acf1 100644 --- a/.babelrc +++ b/.babelrc @@ -1,23 +1,14 @@ { "presets": [ + [ + "env", + { + "targets": { + "browsers": ["last 2 versions", "ie >= 11"] + } + } + ], "react", - "es2015" + "stage-0", ], - - "plugins": [ - "transform-async-to-generator", - "transform-class-properties", - "transform-decorators", - "transform-object-rest-spread", - "transform-runtime" - ], - - "env": { - "build": { - "plugins": [ - ["transform-require-ignore", {"extensions": [".less"] }], - "transform-import-extension-jsx-to-js" - ] - } - } } diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..3714b03 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +example/* +lib/* diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..9ec9372 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,13 @@ +{ + "extends": "airbnb", + "parser": "babel-eslint", + "rules": { + "jsx-a11y/label-has-for": 0, + "jsx-a11y/no-noninteractive-tabindex": 0 + }, + "env": { + "browser": true, + "node": true, + "jest": true + }, +} diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 404f0e9..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1,29 +0,0 @@ -module.exports = { - "parser": "babel-eslint", - "extends": "standard", - "plugins": [ - "standard", - "promise", - "react", - "html" - ], - "rules": { - "no-multi-spaces": "off", - "key-spacing": ["error", { - "align": { - "beforeColon": true, - "afterColon": true, - "on": "colon" - } - }], - "semi": [ - "error", "always" - ], - "no-return-assign": "off", - "react/jsx-uses-react": "error", - "react/jsx-uses-vars": "error", - }, - "env": { - "browser": true - } -}; diff --git a/css/main.css b/css/main.css deleted file mode 100644 index ac2a4bd..0000000 --- a/css/main.css +++ /dev/null @@ -1,2944 +0,0 @@ -.avatar { - vertical-align: middle; -} -.avatar_round { - border-radius: 50%; -} -.button { - border: 0; - box-sizing: border-box; - color: #fff; - cursor: pointer; - display: inline-block; - margin: 0; - overflow: hidden; - padding-bottom: 0; - padding-top: 0; - -webkit-text-decoration-skip: objects; - -webkit-text-size-adjust: 100%; - -ms-text-size-adjust: 100%; - -ms-touch-action: manipulation; - touch-action: manipulation; - text-align: center; - /* .button width */ - /* .button height */ - /* .button rounded */ - /* .button bg */ - /* .button disabled */ - /* .button loading */ -} -.button *, -.button *::before, -.button *::after { - box-sizing: inherit; -} -.button:hover, -.button:focus { - color: #fff; -} -.button:active, -.button:focus { - outline: none; - -moz-outline-style: none; -} -.button::-moz-focus-inner { - border-style: none; - padding: 0; -} -.button[type="button"]:-moz-focusring { - outline: 0; -} -.button::-webkit-file-upload-button { - -webkit-appearance: button; - font: inherit; -} -.button:active { - padding-top: 1px; -} -.button__icon { - display: inline-block; - height: 20px; - position: relative; - vertical-align: top; - width: 20px; -} -.button_width_auto .button__icon, -.button_width_full .button__icon { - margin-right: 10px; -} -.button_height_medium .button__icon { - margin-top: 10px; -} -.button_height_medium:disabled .button__icon { - margin-top: 8px; -} -.button_height_large .button__icon { - margin-top: 20px; -} -.button_height_large:disabled .button__icon { - margin-top: 18px; -} -.button__icon::before { - content: ""; - height: 100%; - position: absolute; - left: 0; - top: 0; - width: 100%; -} -.button_loading .button__icon::before { - display: none; -} -.button__icon-facebook::before { - background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='%23fff'%3E%3Cpath d='M1.1 0C0.5 0 0 0.5 0 1.1L0 18.9C0 19.5 0.5 20 1.1 20L10.7 20 10.7 12.3 8.1 12.3 8.1 9.2 10.7 9.2 10.7 7C10.7 4.4 12.3 3 14.6 3 15.7 3 16.6 3.1 16.9 3.1L16.9 5.8 15.3 5.8C14 5.8 13.8 6.4 13.8 7.3L13.8 9.2 16.8 9.2 16.4 12.3 13.8 12.3 13.8 20 18.9 20C19.5 20 20 19.5 20 18.9L20 1.1C20 0.5 19.5 0 18.9 0L1.1 0Z'/%3E%3C/svg%3E"); -} -.button__icon-google-plus::before { - background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='%23fff'%3E%3Cpath d='M10 8.6L10 12 15.7 12C15.5 13.5 14 16.3 10 16.3 6.6 16.3 3.8 13.5 3.8 10 3.8 6.5 6.6 3.7 10 3.7 11.9 3.7 13.2 4.5 14 5.2L16.7 2.6C15 1 12.7 0 10 0 4.5 0 0 4.5 0 10 0 15.5 4.5 20 10 20 15.8 20 19.6 15.9 19.6 10.2 19.6 9.6 19.5 9.1 19.4 8.6L10 8.6 10 8.6Z'/%3E%3C/svg%3E"); -} -.button__icon-twitter::before { - background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='17' viewBox='0 0 20 17' fill='%23fff'%3E%3Cpath d='M20 1.9C19.3 2.3 18.5 2.5 17.6 2.6 18.5 2.1 19.1 1.3 19.4 0.3 18.7 0.8 17.8 1.1 16.8 1.3 16.1 0.5 15 0 13.8 0 11.6 0 9.7 1.8 9.7 4.1 9.7 4.4 9.8 4.7 9.8 5 6.4 4.9 3.4 3.2 1.4 0.8 1 1.4 0.8 2.1 0.8 2.8 0.8 4.2 1.6 5.5 2.7 6.2 2 6.2 1.4 6 0.8 5.7L0.8 5.8C0.8 7.8 2.2 9.4 4.1 9.8 3.7 9.9 3.4 9.9 3 9.9 2.8 9.9 2.5 9.9 2.2 9.9 2.8 11.5 4.3 12.7 6.1 12.7 4.7 13.8 2.9 14.5 1 14.5 0.6 14.5 0.3 14.4 0 14.4 1.8 15.6 4 16.3 6.3 16.3 13.8 16.3 18 10 18 4.6 18 4.4 18 4.2 18 4 18.8 3.5 19.4 2.8 20 1.9L20 1.9Z'/%3E%3C/svg%3E"); -} -.button__icon-pinterest::before { - background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='%23fff'%3E%3Cpath d='M10 0C4.5 0 0 4.5 0 10 0 14.2 2.6 17.9 6.4 19.3 6.3 18.5 6.2 17.3 6.4 16.4 6.6 15.7 7.6 11.5 7.6 11.5 7.6 11.5 7.3 10.9 7.3 10 7.3 8.6 8.1 7.6 9.1 7.6 9.9 7.6 10.3 8.2 10.3 9 10.3 9.8 9.8 11.1 9.5 12.3 9.3 13.3 10 14.1 11 14.1 12.8 14.1 14.1 12.2 14.1 9.5 14.1 7.1 12.4 5.5 10 5.5 7.1 5.5 5.4 7.6 5.4 9.8 5.4 10.7 5.8 11.6 6.2 12.1 6.3 12.2 6.3 12.3 6.3 12.4 6.2 12.7 6 13.4 6 13.5 5.9 13.7 5.8 13.7 5.6 13.6 4.4 13.1 3.6 11.2 3.6 9.8 3.6 6.6 5.9 3.7 10.2 3.7 13.7 3.7 16.4 6.2 16.4 9.5 16.4 12.9 14.2 15.7 11.2 15.7 10.2 15.7 9.2 15.2 8.9 14.6L8.3 16.9C8.1 17.8 7.4 18.9 7 19.6 8 19.8 9 20 10 20 15.5 20 20 15.5 20 10 20 4.5 15.5 0 10 0L10 0Z'/%3E%3C/svg%3E"); -} -.button__icon-vk::before { - background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='12' viewBox='0 0 20 12' fill='%23fff'%3E%3Cpath d='M11 11.7C11.5 11.7 11.7 11.3 11.7 10.9 11.7 9.3 12.3 8.4 13.4 9.6 14.6 10.8 14.9 11.7 16.4 11.7L19.1 11.7C19.7 11.7 20 11.4 20 11.1 20 10.4 18.8 9.1 17.8 8.2 16.4 6.9 16.4 6.8 17.6 5.3 19.1 3.3 21 0.8 19.3 0.8L16 0.8C15.3 0.8 15.3 1.2 15 1.7 14.2 3.7 12.6 6.2 12 5.8 11.4 5.4 11.7 3.8 11.8 1.5 11.8 0.8 11.8 0.4 10.8 0.2 10.3 0.1 9.8 0 9.3 0 7.4 0 6.1 0.8 6.8 0.9 8.1 1.2 8 4 7.7 5.2 7.2 7.4 5.2 3.5 4.4 1.6 4.1 1.2 4.1 0.8 3.4 0.8L0.7 0.8C0.2 0.8 0 1 0 1.3 0 1.8 2.5 6.9 4.8 9.4 7.1 11.9 9.4 11.7 11 11.7L11 11.7Z'/%3E%3C/svg%3E"); -} -.button_width_square { - color: rgba(0, 0, 0, 0); -} -.button_width_square.button_height_medium { - font-size: 0; - width: 40px; -} -.button_width_square.button_height_large { - font-size: 0; - width: 60px; -} -.button_width_auto { - width: auto; -} -.button_width_full { - width: 100%; -} -.button_height_medium { - font-size: 14px; - height: 40px; - line-height: 40px; -} -.button_height_medium.button_width_auto, -.button_height_medium.button_width_full { - padding-left: 20px; - padding-right: 20px; -} -.button_height_medium.button_width_auto:disabled, -.button_height_medium.button_width_full:disabled { - line-height: 36px; - padding-left: 18px; - padding-right: 18px; -} -.button_height_medium.button_width_auto.button_loading, -.button_height_medium.button_width_full.button_loading { - line-height: 0; -} -.button_height_large { - font-size: 16px; - height: 60px; - line-height: 60px; -} -.button_height_large.button_width_auto, -.button_height_large.button_width_full { - padding-left: 30px; - padding-right: 30px; -} -.button_height_large.button_width_auto:disabled, -.button_height_large.button_width_full:disabled { - line-height: 56px; - padding-left: 28px; - padding-right: 28px; -} -.button_height_large.button_width_auto.button_loading, -.button_height_large.button_width_full.button_loading { - line-height: 0; -} -.button_rounded_all { - border-radius: 3px; -} -.button_rounded_bottom { - border-bottom-left-radius: 3px; - border-bottom-right-radius: 3px; - border-top-left-radius: 0; - border-top-right-radius: 0; -} -.button_bg_1 { - background: linear-gradient(to bottom, #f4511e 0%, #d84315 100%); -} -.button_bg_1:hover, -.button_bg_1:focus { - background: linear-gradient(to bottom, #d84315 0%, #bf360c 100%); -} -.button_bg_1:active { - background: linear-gradient(to bottom, #9c2500 0%, #bf360c 100%); -} -.button_bg_2 { - background: linear-gradient(to bottom, #42a5f5 0%, #2196f3 100%); -} -.button_bg_2:hover, -.button_bg_2:focus { - background: linear-gradient(to bottom, #2196f3 0%, #1976d2 100%); -} -.button_bg_2:active { - background: linear-gradient(to bottom, #0d47a1 0%, #1976d2 100%); -} -.button_bg_3 { - background: linear-gradient(to bottom, #90a4ae 0%, #78909c 100%); -} -.button_bg_3:hover, -.button_bg_3:focus { - background: linear-gradient(to bottom, #78909c 0%, #546e7a 100%); -} -.button_bg_3:active { - background: linear-gradient(to bottom, #455a64 0%, #546e7a 100%); -} -.button_bg_facebook { - background: linear-gradient(to bottom, #4f69a3 0%, #415b93 100%); -} -.button_bg_facebook:hover, -.button_bg_facebook:focus { - background: linear-gradient(to bottom, #415b93 0%, #324d89 100%); -} -.button_bg_facebook:active { - background: linear-gradient(to bottom, #24407d 0%, #324d89 100%); -} -.button_bg_google-plus { - background: linear-gradient(to bottom, #db4937 0%, #c43a2e 100%); -} -.button_bg_google-plus:hover, -.button_bg_google-plus:focus { - background: linear-gradient(to bottom, #c43a2e 0%, #ba2b1f 100%); -} -.button_bg_google-plus:active { - background: linear-gradient(to bottom, #a91e13 0%, #ba2b1f 100%); -} -.button_bg_twitter { - background: linear-gradient(to bottom, #56acee 0%, #4f9fdb 100%); -} -.button_bg_twitter:hover, -.button_bg_twitter:focus { - background: linear-gradient(to bottom, #4f9fdb 0%, #3a8ece 100%); -} -.button_bg_twitter:active { - background: linear-gradient(to bottom, #227abe 0%, #3a8ece 100%); -} -.button_bg_pinterest { - background: linear-gradient(to bottom, #e3262d 0%, #cb2026 100%); -} -.button_bg_pinterest:hover, -.button_bg_pinterest:focus { - background: linear-gradient(to bottom, #cb2026 0%, #b70f15 100%); -} -.button_bg_pinterest:active { - background: linear-gradient(to bottom, #9f0006 0%, #b70f15 100%); -} -.button_bg_vk { - background: linear-gradient(to bottom, #5b7fa6 0%, #346184 100%); -} -.button_bg_vk:hover, -.button_bg_vk:focus { - background: linear-gradient(to bottom, #346184 0%, #1d4b6e 100%); -} -.button_bg_vk:active { - background: linear-gradient(to bottom, #113b5a 0%, #1d4b6e 100%); -} -.button:disabled { - background: rgba(0, 0, 0, 0); - border: 2px solid #b0bec5; - cursor: not-allowed; -} -.button:disabled:not(.button_width_square) { - color: #b0bec5; -} -.button:disabled .button__icon-facebook::before { - background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='%23b0bec5'%3E%3Cpath d='M1.1 0C0.5 0 0 0.5 0 1.1L0 18.9C0 19.5 0.5 20 1.1 20L10.7 20 10.7 12.3 8.1 12.3 8.1 9.2 10.7 9.2 10.7 7C10.7 4.4 12.3 3 14.6 3 15.7 3 16.6 3.1 16.9 3.1L16.9 5.8 15.3 5.8C14 5.8 13.8 6.4 13.8 7.3L13.8 9.2 16.8 9.2 16.4 12.3 13.8 12.3 13.8 20 18.9 20C19.5 20 20 19.5 20 18.9L20 1.1C20 0.5 19.5 0 18.9 0L1.1 0Z'/%3E%3C/svg%3E"); -} -.button_loading { - font-size: 0; - vertical-align: middle; -} -.tm-quark-checkbox { - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; - box-sizing: border-box; - cursor: default; - display: -webkit-inline-box; - display: -ms-inline-flexbox; - display: inline-flex; - -webkit-box-orient: horizontal; - -webkit-box-direction: normal; - -ms-flex-flow: row nowrap; - flex-flow: row nowrap; - -ms-touch-action: manipulation; - touch-action: manipulation; - -webkit-text-size-adjust: 100%; - -ms-text-size-adjust: 100%; -} -.tm-quark-checkbox *, -.tm-quark-checkbox *::before, -.tm-quark-checkbox *::after { - box-sizing: inherit; -} -.tm-quark-checkbox:focus { - outline: none; -} -.tm-quark-checkbox__icon { - background-color: transparent; - border: 2px solid; - border-radius: 3px; - color: #cfd8dc; - height: 20px; - min-height: 20px; - min-width: 20px; - width: 20px; -} -.tm-quark-checkbox__label { - padding-left: 10px; -} -.tm-quark-checkbox__input { - display: none; -} -.tm-quark-checkbox__input:checked + .tm-quark-checkbox__icon { - background-color: #1ab744; - color: #1ab744; -} -.tm-quark-checkbox__input:checked + .tm-quark-checkbox__icon::before { - border-bottom: 2px solid; - border-right: 2px solid; - color: #fff; - content: ""; - display: block; - height: 14px; - margin-left: 3px; - margin-right: 3px; - margin-top: -1px; - -webkit-transform: rotate(45deg); - transform: rotate(45deg); - width: 10px; -} -.tm-quark-checkbox__input:checked ~ .tm-quark-checkbox__label { - color: #1ab744; - font-weight: 700; -} -.tm-quark-checkbox__input:disabled + .tm-quark-checkbox__icon, -.tm-quark-checkbox__input:disabled ~ .tm-quark-checkbox__label { - cursor: not-allowed; -} -.tm-quark-checkbox__input:disabled + .tm-quark-checkbox__icon { - background-color: transparent; - border-color: #eceff1; -} -.tm-quark-checkbox__input:disabled:checked + .tm-quark-checkbox__icon { - border-color: #cfd8dc; - background-color: #cfd8dc; -} -.tm-quark-checkbox__input:disabled ~ .tm-quark-checkbox__label { - color: #cfd8dc; -} -.tm-quark-checkbox__input:not(:disabled) + .tm-quark-checkbox__icon, -.tm-quark-checkbox__input:not(:disabled) ~ .tm-quark-checkbox__label { - cursor: pointer; -} -.tm-quark-checkbox:hover .tm-quark-checkbox__input:not(:disabled) + .tm-quark-checkbox__icon, -.tm-quark-checkbox:active .tm-quark-checkbox__input:not(:disabled) + .tm-quark-checkbox__icon { - color: #1ab744; -} -.tm-quark-checkbox:hover .tm-quark-checkbox__input:not(:disabled) ~ .tm-quark-checkbox__label, -.tm-quark-checkbox:active .tm-quark-checkbox__input:not(:disabled) ~ .tm-quark-checkbox__label { - color: #1ab744; -} -.tm-quark-checkbox:active .tm-quark-checkbox__input:not(:disabled) + .tm-quark-checkbox__icon { - background-color: #1ab744; - -webkit-transform: scale(0.8) translateY(1px); - transform: scale(0.8) translateY(1px); -} -.tm-quark-checkbox:active .tm-quark-checkbox__input:not(:disabled) + .tm-quark-checkbox__icon::before { - color: transparent; -} -.tm-quark-checkbox:active .tm-quark-checkbox__input:not(:disabled) ~ .tm-quark-checkbox__label { - -webkit-transform: translateY(1px); - transform: translateY(1px); -} -.tm-quark-dropdown { - -webkit-box-align: stretch; - -ms-flex-align: stretch; - align-items: stretch; - box-sizing: border-box; - font-size: 14px; - line-height: 1; - position: relative; - text-align: left; -} -.tm-quark-dropdown *, -.tm-quark-dropdown *::before, -.tm-quark-dropdown *::after { - box-sizing: border-box; -} -.tm-quark-dropdown:focus { - outline: none; -} -.tm-quark-dropdown_type_1 { - display: -webkit-inline-box; - display: -ms-inline-flexbox; - display: inline-flex; - background: linear-gradient(to bottom, #eceff1 0%, #dde3e6 100%); - border-radius: 3px; - box-shadow: inset 0 -1px 0 0 #cfd8dc; - -webkit-box-orient: horizontal; - -webkit-box-direction: normal; - -ms-flex-flow: row nowrap; - flex-flow: row nowrap; - height: 40px; - padding-left: 20px; - -webkit-box-pack: justify; - -ms-flex-pack: justify; - justify-content: space-between; -} -.tm-quark-dropdown_type_1.tm-quark-dropdown_disabled::before { - height: 40px; - top: 0; -} -.tm-quark-dropdown_type_1.tm-quark-dropdown_open-position_top .tm-quark-dropdown__content { - border-bottom-left-radius: 3px; -} -.tm-quark-dropdown_type_1.tm-quark-dropdown_open-position_bottom .tm-quark-dropdown__content { - border-top-left-radius: 3px; -} -.tm-quark-dropdown_type_1 .tm-quark-dropdown__button { - margin-left: auto; -} -.tm-quark-dropdown_type_2 { - display: -webkit-inline-box; - display: -ms-inline-flexbox; - display: inline-flex; - -webkit-box-orient: vertical; - -webkit-box-direction: normal; - -ms-flex-flow: column wrap; - flex-flow: column wrap; -} -.tm-quark-dropdown_type_2.tm-quark-dropdown_disabled::before { - height: 40px; - bottom: 0; -} -.tm-quark-dropdown_type_3 { - display: -webkit-box; - display: -ms-flexbox; - display: flex; - -webkit-box-orient: vertical; - -webkit-box-direction: normal; - -ms-flex-flow: column wrap; - flex-flow: column wrap; -} -.tm-quark-dropdown_type_3.tm-quark-dropdown_disabled::before { - height: 60px; - top: 0; -} -.tm-quark-dropdown_type_4 { - display: -webkit-box; - display: -ms-flexbox; - display: flex; - -webkit-box-orient: horizontal; - -webkit-box-direction: normal; - -ms-flex-flow: row wrap; - flex-flow: row wrap; -} -.tm-quark-dropdown_type_4.tm-quark-dropdown_disabled::before { - height: 100%; - top: 0; -} -.tm-quark-dropdown_type_5 { - display: -webkit-box; - display: -ms-flexbox; - display: flex; -} -.tm-quark-dropdown_type_5 .tm-quark-dropdown__content { - border-radius: 3px; - padding-top: 10px; -} -.tm-quark-dropdown_type_5 .tm-quark-dropdown__content::before { - background-color: #546e7a; - content: ""; - position: absolute; - left: 50%; - width: 16px; - height: 16px; - -webkit-transform: rotate(45deg) translateX(-50%); - transform: rotate(45deg) translateX(-50%); - z-index: -1; -} -.tm-quark-dropdown_open-position_top .tm-quark-dropdown_type_5 .tm-quark-dropdown__content::before { - bottom: -8px; - border-bottom-right-radius: 3px; -} -.tm-quark-dropdown_open-position_bottom .tm-quark-dropdown_type_5 .tm-quark-dropdown__content::before { - border-top-left-radius: 3px; - top: 8px; -} -.tm-quark-dropdown_type_6 { - display: -webkit-box; - display: -ms-flexbox; - display: flex; - -webkit-box-orient: horizontal; - -webkit-box-direction: normal; - -ms-flex-flow: row wrap; - flex-flow: row wrap; - -webkit-box-pack: end; - -ms-flex-pack: end; - justify-content: flex-end; -} -.tm-quark-dropdown_type_6.tm-quark-dropdown_open-position_top .tm-quark-dropdown__content { - border-bottom-left-radius: 3px; -} -.tm-quark-dropdown_type_6.tm-quark-dropdown_open-position_bottom .tm-quark-dropdown__content { - border-top-left-radius: 3px; -} -.tm-quark-dropdown_type_7 { - display: -webkit-box; - display: -ms-flexbox; - display: flex; -} -.tm-quark-dropdown_disabled { - background: transparent; - box-shadow: none; - pointer-events: none; - overflow: hidden; - opacity: .5; -} -.tm-quark-dropdown_disabled::before { - border: 1px solid #cfd8dc; - border-radius: 3px; - content: ""; - left: 1px; - position: absolute; - right: 1px; - z-index: 1; -} -.tm-quark-dropdown__label { - color: #90a4ae; - cursor: default; - padding-right: 20px; - white-space: nowrap; -} -.tm-quark-dropdown__label_disabled { - color: #cfd8dc; -} -.tm-quark-dropdown__label_size_small { - line-height: 1; - font-size: 11px; -} -.tm-quark-dropdown__label_size_medium { - line-height: 40px; -} -.tm-quark-dropdown__button { - background: linear-gradient(to bottom, #eceff1 0%, #dde3e6 100%); - border-radius: 3px; - box-shadow: inset 0 -1px 0 0 #cfd8dc; - cursor: pointer; - color: #243238; - display: -webkit-box; - display: -ms-flexbox; - display: flex; - -webkit-box-orient: horizontal; - -webkit-box-direction: normal; - -ms-flex-flow: row wrap; - flex-flow: row wrap; - -webkit-box-align: stretch; - -ms-flex-align: stretch; - align-items: stretch; - line-height: 20px; - text-align: left; - overflow: hidden; -} -.tm-quark-dropdown__button_size_medium { - padding: 10px 20px; -} -.tm-quark-dropdown__button_size_medium:active { - padding: 11px 20px 9px; -} -.tm-quark-dropdown__button_size_large { - padding: 20px 20px; -} -.tm-quark-dropdown__button_size_large:active { - padding: 21px 20px 19px; -} -.tm-quark-dropdown__button_disabled { - background: transparent; - color: #cfd8dc; -} -.tm-quark-dropdown__button-inner { - display: -webkit-box; - display: -ms-flexbox; - display: flex; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; - -webkit-box-orient: horizontal; - -webkit-box-direction: normal; - -ms-flex-flow: row wrap; - flex-flow: row wrap; - width: 100%; -} -.tm-quark-dropdown__button-arrow { - border-bottom: 2px solid; - border-right: 2px solid; - content: ""; - width: 7px; - height: 7px; - margin-left: auto; - -webkit-transform: rotate(45deg); - transform: rotate(45deg); - transition: -webkit-transform 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55); - transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55); - transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55), -webkit-transform 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55); -} -.tm-quark-dropdown__button .tm-quark-dropdown__label { - cursor: pointer; - margin-bottom: 5px; - margin-top: -8px; - width: 100%; -} -.tm-quark-dropdown__button:hover, -.tm-quark-dropdown__button:focus, -.tm-quark-dropdown__button:active, -.tm-quark-dropdown__button_open { - color: #fff; -} -.tm-quark-dropdown__button:hover, -.tm-quark-dropdown__button:focus { - background: linear-gradient(to bottom, #78909c 0%, #546e7a 100%); - box-shadow: inset 0 -1px 0 0 #546e7a; -} -.tm-quark-dropdown__button:focus { - outline: none; -} -.tm-quark-dropdown__button:active { - background: linear-gradient(to bottom, #455a64 0%, #546e7a 100%); - box-shadow: inset 0 -1px 0 0 #546e7a; -} -.tm-quark-dropdown__button_open { - background: #546e7a; - box-shadow: none; -} -.tm-quark-dropdown_open-position_bottom .tm-quark-dropdown__button_open { - border-radius: 3px 3px 0 0; -} -.tm-quark-dropdown_open-position_top .tm-quark-dropdown__button_open { - border-radius: 0 0 3px 3px ; -} -.tm-quark-dropdown__button_open .tm-quark-dropdown__button-arrow { - -webkit-transform: rotate(-135deg); - transform: rotate(-135deg); -} -.tm-quark-dropdown__button-content { - display: -webkit-inline-box; - display: -ms-inline-flexbox; - display: inline-flex; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; - padding-right: 10px; - width: calc(100% - 10px); - white-space: nowrap; - text-overflow: ellipsis; - overflow: hidden; -} -.tm-quark-dropdown__label ~ .tm-quark-dropdown__button-content { - margin-bottom: -8px; -} -.tm-quark-dropdown__button-label-content { - overflow: hidden; - text-overflow: ellipsis; -} -.tm-quark-dropdown__icon_size_medium { - height: 20px; - margin-right: 10px; - min-width: 20px; - width: 20px; -} -.tm-quark-dropdown__icon_size_large { - height: 30px; - margin-right: 20px; - min-width: 30px; - width: 30px; -} -.tm-quark-dropdown__icon_type_radio { - -ms-flex-item-align: start; - align-self: flex-start; - border-radius: 50%; - border: 2px solid #78909c; -} -.tm-quark-dropdown__option:hover .tm-quark-dropdown__icon_type_radio { - border-color: #fff; -} -.tm-quark-dropdown__option:active .tm-quark-dropdown__icon_type_radio, -.tm-quark-dropdown__option_selected .tm-quark-dropdown__icon_type_radio { - border-color: transparent; - background-color: #fff; -} -.tm-quark-dropdown__content { - box-shadow: 0 5px 10px 0 rgba(36, 50, 56, 0.2); - overflow: hidden; - position: absolute; - left: 0; - -webkit-transform: scale(0); - transform: scale(0); - width: 100%; - z-index: 1; -} -.tm-quark-dropdown_open-position_top .tm-quark-dropdown__content { - border-top-left-radius: 3px; - border-top-right-radius: 3px; - box-shadow: 0 -5px 10px 0 rgba(36, 50, 56, 0.2); - bottom: 100%; - -webkit-transform-origin: 100% 100%; - transform-origin: 100% 100%; -} -.tm-quark-dropdown_open-position_bottom .tm-quark-dropdown__content { - border-bottom-left-radius: 3px; - border-bottom-right-radius: 3px; - box-shadow: 0 5px 10px 0 rgba(36, 50, 56, 0.2); - top: 100%; - -webkit-transform-origin: 0 0; - transform-origin: 0 0; -} -.tm-quark-dropdown__content_animate_show { - -webkit-animation: TMQuarkDropdownOpenContent 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; - animation: TMQuarkDropdownOpenContent 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; -} -@-webkit-keyframes TMQuarkDropdownOpenContent { - from { - opacity: 0; - -webkit-transform: scaleY(0); - transform: scaleY(0); - } - to { - opacity: 1; - -webkit-transform: scaleY(1); - transform: scaleY(1); - } -} -@keyframes TMQuarkDropdownOpenContent { - from { - opacity: 0; - -webkit-transform: scaleY(0); - transform: scaleY(0); - } - to { - opacity: 1; - -webkit-transform: scaleY(1); - transform: scaleY(1); - } -} -.tm-quark-dropdown__content_animate_hide { - -webkit-animation: TMQuarkDropdownCloseContent 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; - animation: TMQuarkDropdownCloseContent 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; -} -@-webkit-keyframes TMQuarkDropdownCloseContent { - from { - opacity: 1; - -webkit-transform: scaleY(1); - transform: scaleY(1); - } - to { - opacity: 0; - -webkit-transform: scaleY(0); - transform: scaleY(0); - } -} -@keyframes TMQuarkDropdownCloseContent { - from { - opacity: 1; - -webkit-transform: scaleY(1); - transform: scaleY(1); - } - to { - opacity: 0; - -webkit-transform: scaleY(0); - transform: scaleY(0); - } -} -.tm-quark-dropdown__filter-box { - background-color: #546e7a; - padding: 20px; -} -.tm-quark-dropdown__filter-input { - background-color: #eceff1; - box-shadow: inset 0 1px 0 #cfd8dc; - border: 0; - border-radius: 3px; - color: #243238; - display: block; - font-size: 14px; - height: 40px; - line-height: 20px; - padding: 0 20px; - width: 100%; - -webkit-appearance: none; -} -.tm-quark-dropdown__filter-input::-webkit-input-placeholder { - color: #90a4ae; -} -.tm-quark-dropdown__filter-input:-ms-input-placeholder { - color: #90a4ae; -} -.tm-quark-dropdown__filter-input::placeholder { - color: #90a4ae; -} -.tm-quark-dropdown__filter-input:focus { - border: 1px solid #90caf9; - box-shadow: none; - outline: none; - -webkit-appearance: none; -} -.tm-quark-dropdown__filter-input:focus::-webkit-input-placeholder { - color: #bbdefb; -} -.tm-quark-dropdown__filter-input:focus:-ms-input-placeholder { - color: #bbdefb; -} -.tm-quark-dropdown__filter-input:focus::placeholder { - color: #bbdefb; -} -.tm-quark-dropdown__options { - background-color: #546e7a; - list-style: none; - padding: 0; - margin: 0; -} -.tm-quark-dropdown__option { - background-color: #546e7a; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; - border-top: 1px solid #455a64; - color: #fff; - cursor: pointer; - display: -webkit-box; - display: -ms-flexbox; - display: flex; - line-height: 20px; -} -.tm-quark-dropdown__option:first-child { - border-top-color: transparent; -} -.tm-quark-dropdown__filter-box + .tm-quark-dropdown__options .tm-quark-dropdown__option:first-child { - border-top-color: #455a64; -} -.tm-quark-dropdown__filter-box + .tm-quark-dropdown__options .tm-quark-dropdown__option:first-child:hover { - border-top-color: #2196f3; -} -.tm-quark-dropdown__filter-box + .tm-quark-dropdown__options .tm-quark-dropdown__option:first-child:focus { - border-top-color: #2196f3; -} -.tm-quark-dropdown__filter-box + .tm-quark-dropdown__options .tm-quark-dropdown__option:first-child:active, -.tm-quark-dropdown__filter-box + .tm-quark-dropdown__options .tm-quark-dropdown__option:first-child.tm-quark-dropdown__option_selected { - border-top-color: #1976d2; -} -.tm-quark-dropdown__option_disabled { - color: #78909c; - opacity: .5; - pointer-events: none; -} -.tm-quark-dropdown__option_type_no-filter-results { - pointer-events: none; -} -.tm-quark-dropdown__option_size_medium { - padding: 10px 20px; -} -.tm-quark-dropdown__option_size_medium:active { - padding: 11px 20px 9px; -} -.tm-quark-dropdown__option_size_large { - padding: 20px; -} -.tm-quark-dropdown__option_size_large:active { - padding: 21px 20px 19px; -} -.tm-quark-dropdown__option:hover { - background-color: #2196f3; - border-color: #2196f3; -} -.tm-quark-dropdown__option:hover + .tm-quark-dropdown__option { - border-top-color: #2196f3; -} -.tm-quark-dropdown__option:focus { - outline: none; - background-color: #2196f3; - border-color: #2196f3; -} -.tm-quark-dropdown__option:focus + .tm-quark-dropdown__option { - border-top-color: #2196f3; -} -.tm-quark-dropdown__option:active, -.tm-quark-dropdown__option_selected { - background-color: #1976d2; - border-color: #1976d2; -} -.tm-quark-dropdown__option:active + .tm-quark-dropdown__option, -.tm-quark-dropdown__option_selected + .tm-quark-dropdown__option { - border-top-color: #1976d2; -} -.tm-quark-notification { - box-sizing: border-box; - display: -webkit-box; - display: -ms-flexbox; - display: flex; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; - color: #fff; - padding-left: 20px; - padding-right: 20px; -} -.tm-quark-notification *, -.tm-quark-notification *::before, -.tm-quark-notification *::after { - box-sizing: inherit; -} -.tm-quark-notification_position_absolute { - position: absolute; -} -.tm-quark-notification_position_fixed { - position: fixed; -} -.tm-quark-notification_position_relative { - position: relative; -} -.tm-quark-notification_placement_left, -.tm-quark-notification_placement_right, -.tm-quark-notification_placement_top, -.tm-quark-notification_placement_bottom { - border-radius: 3px; -} -.tm-quark-notification_placement_left, -.tm-quark-notification_placement_right { - top: 50%; -} -.tm-quark-notification_placement_top, -.tm-quark-notification_placement_bottom { - left: 50%; -} -.tm-quark-notification_placement_left { - left: 0; -} -.tm-quark-notification_placement_left.tm-quark-notification_visible { - -webkit-animation: TMQuarkNotificationShowToLeft 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; - animation: TMQuarkNotificationShowToLeft 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; -} -@-webkit-keyframes TMQuarkNotificationShowToLeft { - from { - margin-left: -60px; - opacity: 0; - -webkit-transform: translateY(-50%) translateX(-100%) scale(0.8); - transform: translateY(-50%) translateX(-100%) scale(0.8); - } - to { - margin-left: -20px; - -webkit-transform: translateY(-50%) translateX(-100%) scale(1); - transform: translateY(-50%) translateX(-100%) scale(1); - opacity: 1; - } -} -@keyframes TMQuarkNotificationShowToLeft { - from { - margin-left: -60px; - opacity: 0; - -webkit-transform: translateY(-50%) translateX(-100%) scale(0.8); - transform: translateY(-50%) translateX(-100%) scale(0.8); - } - to { - margin-left: -20px; - -webkit-transform: translateY(-50%) translateX(-100%) scale(1); - transform: translateY(-50%) translateX(-100%) scale(1); - opacity: 1; - } -} -.tm-quark-notification_placement_left.tm-quark-notification_hidden { - -webkit-animation: TMQuarkNotificationHideFromLeft 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; - animation: TMQuarkNotificationHideFromLeft 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; -} -@-webkit-keyframes TMQuarkNotificationHideFromLeft { - from { - margin-left: -20px; - opacity: 1; - -webkit-transform: translateY(-50%) translateX(-100%) scale(1); - transform: translateY(-50%) translateX(-100%) scale(1); - } - to { - margin-left: -60px; - opacity: 0; - -webkit-transform: translateY(-50%) translateX(-100%) scale(0.8); - transform: translateY(-50%) translateX(-100%) scale(0.8); - } -} -@keyframes TMQuarkNotificationHideFromLeft { - from { - margin-left: -20px; - opacity: 1; - -webkit-transform: translateY(-50%) translateX(-100%) scale(1); - transform: translateY(-50%) translateX(-100%) scale(1); - } - to { - margin-left: -60px; - opacity: 0; - -webkit-transform: translateY(-50%) translateX(-100%) scale(0.8); - transform: translateY(-50%) translateX(-100%) scale(0.8); - } -} -.tm-quark-notification_placement_top { - top: 0; -} -.tm-quark-notification_placement_top.tm-quark-notification_visible { - -webkit-animation: TMQuarkNotificationShowToTop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; - animation: TMQuarkNotificationShowToTop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; -} -@-webkit-keyframes TMQuarkNotificationShowToTop { - from { - margin-top: -60px; - opacity: 0; - -webkit-transform: translateY(-100%) translateX(-50%) scale(0.8); - transform: translateY(-100%) translateX(-50%) scale(0.8); - } - to { - margin-top: -20px; - -webkit-transform: translateY(-100%) translateX(-50%) scale(1); - transform: translateY(-100%) translateX(-50%) scale(1); - opacity: 1; - } -} -@keyframes TMQuarkNotificationShowToTop { - from { - margin-top: -60px; - opacity: 0; - -webkit-transform: translateY(-100%) translateX(-50%) scale(0.8); - transform: translateY(-100%) translateX(-50%) scale(0.8); - } - to { - margin-top: -20px; - -webkit-transform: translateY(-100%) translateX(-50%) scale(1); - transform: translateY(-100%) translateX(-50%) scale(1); - opacity: 1; - } -} -.tm-quark-notification_placement_top.tm-quark-notification_hidden { - -webkit-animation: TMQuarkNotificationHideFromTop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; - animation: TMQuarkNotificationHideFromTop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; -} -@-webkit-keyframes TMQuarkNotificationHideFromTop { - from { - margin-top: -20px; - opacity: 1; - -webkit-transform: translateY(-100%) translateX(-50%) scale(1); - transform: translateY(-100%) translateX(-50%) scale(1); - } - to { - margin-top: -60px; - opacity: 0; - -webkit-transform: translateY(-100%) translateX(-50%) scale(0.8); - transform: translateY(-100%) translateX(-50%) scale(0.8); - } -} -@keyframes TMQuarkNotificationHideFromTop { - from { - margin-top: -20px; - opacity: 1; - -webkit-transform: translateY(-100%) translateX(-50%) scale(1); - transform: translateY(-100%) translateX(-50%) scale(1); - } - to { - margin-top: -60px; - opacity: 0; - -webkit-transform: translateY(-100%) translateX(-50%) scale(0.8); - transform: translateY(-100%) translateX(-50%) scale(0.8); - } -} -.tm-quark-notification_placement_bottom { - bottom: 0; -} -.tm-quark-notification_placement_bottom.tm-quark-notification_visible { - -webkit-animation: TMQuarkNotificationShowToBottom 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; - animation: TMQuarkNotificationShowToBottom 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; -} -@-webkit-keyframes TMQuarkNotificationShowToBottom { - from { - margin-bottom: -60px; - opacity: 0; - -webkit-transform: translateY(100%) translateX(-50%) scale(0.8); - transform: translateY(100%) translateX(-50%) scale(0.8); - } - to { - margin-bottom: -20px; - -webkit-transform: translateY(100%) translateX(-50%) scale(1); - transform: translateY(100%) translateX(-50%) scale(1); - opacity: 1; - } -} -@keyframes TMQuarkNotificationShowToBottom { - from { - margin-bottom: -60px; - opacity: 0; - -webkit-transform: translateY(100%) translateX(-50%) scale(0.8); - transform: translateY(100%) translateX(-50%) scale(0.8); - } - to { - margin-bottom: -20px; - -webkit-transform: translateY(100%) translateX(-50%) scale(1); - transform: translateY(100%) translateX(-50%) scale(1); - opacity: 1; - } -} -.tm-quark-notification_placement_bottom.tm-quark-notification_hidden { - -webkit-animation: TMQuarkNotificationHideFromBottom 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; - animation: TMQuarkNotificationHideFromBottom 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; -} -@-webkit-keyframes TMQuarkNotificationHideFromBottom { - from { - margin-bottom: -20px; - opacity: 1; - -webkit-transform: translateY(100%) translateX(-50%) scale(1); - transform: translateY(100%) translateX(-50%) scale(1); - } - to { - margin-bottom: -60px; - opacity: 0; - -webkit-transform: translateY(100%) translateX(-50%) scale(0.8); - transform: translateY(100%) translateX(-50%) scale(0.8); - } -} -@keyframes TMQuarkNotificationHideFromBottom { - from { - margin-bottom: -20px; - opacity: 1; - -webkit-transform: translateY(100%) translateX(-50%) scale(1); - transform: translateY(100%) translateX(-50%) scale(1); - } - to { - margin-bottom: -60px; - opacity: 0; - -webkit-transform: translateY(100%) translateX(-50%) scale(0.8); - transform: translateY(100%) translateX(-50%) scale(0.8); - } -} -.tm-quark-notification_placement_right { - right: 0; -} -.tm-quark-notification_placement_right.tm-quark-notification_visible { - -webkit-animation: TMQuarkNotificationShowToRight 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; - animation: TMQuarkNotificationShowToRight 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; -} -@-webkit-keyframes TMQuarkNotificationShowToRight { - from { - margin-right: -60px; - opacity: 0; - -webkit-transform: translateY(-50%) translateX(100%) scale(0.8); - transform: translateY(-50%) translateX(100%) scale(0.8); - } - to { - margin-right: -20px; - -webkit-transform: translateY(-50%) translateX(100%) scale(1); - transform: translateY(-50%) translateX(100%) scale(1); - opacity: 1; - } -} -@keyframes TMQuarkNotificationShowToRight { - from { - margin-right: -60px; - opacity: 0; - -webkit-transform: translateY(-50%) translateX(100%) scale(0.8); - transform: translateY(-50%) translateX(100%) scale(0.8); - } - to { - margin-right: -20px; - -webkit-transform: translateY(-50%) translateX(100%) scale(1); - transform: translateY(-50%) translateX(100%) scale(1); - opacity: 1; - } -} -.tm-quark-notification_placement_right.tm-quark-notification_hidden { - -webkit-animation: TMQuarkNotificationHideFromRight 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; - animation: TMQuarkNotificationHideFromRight 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; -} -@-webkit-keyframes TMQuarkNotificationHideFromRight { - from { - margin-right: -20px; - -webkit-transform: translateY(-50%) translateX(100%) scale(1); - transform: translateY(-50%) translateX(100%) scale(1); - opacity: 1; - } - to { - margin-right: -60px; - opacity: 0; - -webkit-transform: translateY(-50%) translateX(100%) scale(0.8); - transform: translateY(-50%) translateX(100%) scale(0.8); - } -} -@keyframes TMQuarkNotificationHideFromRight { - from { - margin-right: -20px; - -webkit-transform: translateY(-50%) translateX(100%) scale(1); - transform: translateY(-50%) translateX(100%) scale(1); - opacity: 1; - } - to { - margin-right: -60px; - opacity: 0; - -webkit-transform: translateY(-50%) translateX(100%) scale(0.8); - transform: translateY(-50%) translateX(100%) scale(0.8); - } -} -.tm-quark-notification_height_fixed-small { - font-size: 13px; - line-height: 20px; - height: 40px; - padding-top: 10px; - padding-bottom: 10px; -} -.tm-quark-notification_height_fixed-medium { - height: 60px; -} -.tm-quark-notification_height_auto { - padding-bottom: 20px; - padding-top: 20px; -} -.tm-quark-notification_type_default { - color: #546e7a; - background-color: #546e7a; - box-shadow: 0 5px 10px 0 rgba(36, 35, 56, 0.2); -} -.tm-quark-notification_type_success { - color: #1ab744; - background-color: #1ab744; - box-shadow: 0 5px 10px 0 rgba(0, 96, 35, 0.2); -} -.tm-quark-notification_type_error { - color: #d84315; - background-color: #d84315; - box-shadow: 0 5px 10px 0 rgba(191, 54, 12, 0.2); -} -.tm-quark-notification_type_warning { - background-color: #ff8f00; - box-shadow: 0 5px 10px 0 rgba(255, 111, 0, 0.2); -} -.tm-quark-notification_arrow-placement_left::before, -.tm-quark-notification_arrow-placement_top::before, -.tm-quark-notification_arrow-placement_bottom::before, -.tm-quark-notification_arrow-placement_right::before { - border: 8px solid; - border-radius: 3px; - content: ""; - position: absolute; -} -.tm-quark-notification_arrow-placement_left::before, -.tm-quark-notification_arrow-placement_right::before { - top: 50%; -} -.tm-quark-notification_arrow-placement_top::before, -.tm-quark-notification_arrow-placement_bottom::before { - left: 50%; -} -.tm-quark-notification_arrow-placement_left::before { - left: -6px; - -webkit-transform: translateY(-50%) rotate(45deg); - transform: translateY(-50%) rotate(45deg); -} -.tm-quark-notification_arrow-placement_top::before { - -webkit-transform: translateX(-50%) rotate(45deg); - transform: translateX(-50%) rotate(45deg); - top: -6px; -} -.tm-quark-notification_arrow-placement_bottom::before { - -webkit-transform: translateX(-50%) rotate(45deg); - transform: translateX(-50%) rotate(45deg); - bottom: -6px; -} -.tm-quark-notification_arrow-placement_right::before { - right: -6px; - -webkit-transform: translateY(-50%) rotate(45deg); - transform: translateY(-50%) rotate(45deg); -} -.tm-quark-notification__content { - color: #fff; - position: relative; - white-space: nowrap; - width: 100%; -} -.tm-quark-field { - box-sizing: border-box; - display: -webkit-box; - display: -ms-flexbox; - display: flex; - position: relative; - width: 100%; -} -.tm-quark-field *, -.tm-quark-field *::before, -.tm-quark-field *::after { - box-sizing: inherit; -} -.tm-quark-field_size_medium { - height: 40px; -} -.tm-quark-field_size_large { - height: 60px; -} -.tm-quark-field__input { - background-color: #eceff1; - border: 1px solid transparent; - box-shadow: inset 0 1px 0 0 #cfd8dc; - border-radius: 3px; - color: #243238; - margin: 0; - padding-left: 19px; - padding-right: 19px; - -ms-touch-action: manipulation; - touch-action: manipulation; - overflow: visible; - width: 100%; -} -.tm-quark-field__input[type="number"]::-webkit-inner-spin-button, -.tm-quark-field__input[type="number"]::-webkit-outer-spin-button { - height: auto; -} -.tm-quark-field__input[type="search"] { - -webkit-appearance: textfield; - outline-offset: -2px; -} -.tm-quark-field__input[type="search"]::-webkit-search-cancel-button, -.tm-quark-field__input[type="search"]::-webkit-search-decoration { - -webkit-appearance: none; -} -.tm-quark-field__input::-ms-clear { - display: none; -} -.tm-quark-field__input::-ms-reveal { - display: none; -} -.tm-quark-field__input::-webkit-outer-spin-button, -.tm-quark-field__input::-webkit-inner-spin-button { - -webkit-appearance: none; - margin: 0; -} -.tm-quark-field__input[type=number] { - -moz-appearance: textfield; - -webkit-appearance: textfield; - appearance: textfield; -} -.tm-quark-field__input_with-icon { - padding-left: 49px; -} -.tm-quark-field__input_size_medium { - font-size: 14px; - line-height: 20px; - height: 40px; - padding-top: 9px; - padding-bottom: 9px; -} -.tm-quark-field__input_size_medium::-webkit-input-placeholder { - color: #90a4ae; -} -.tm-quark-field__input_size_medium:-ms-input-placeholder { - color: #90a4ae; -} -.tm-quark-field__input_size_medium::placeholder { - color: #90a4ae; -} -.tm-quark-field__input_size_medium:focus::-webkit-input-placeholder { - color: #bbdefb; -} -.tm-quark-field__input_size_medium:focus:-ms-input-placeholder { - color: #bbdefb; -} -.tm-quark-field__input_size_medium:focus::placeholder { - color: #bbdefb; -} -.tm-quark-field__input_size_medium:disabled::-webkit-input-placeholder { - color: #cfd8dc; -} -.tm-quark-field__input_size_medium:disabled:-ms-input-placeholder { - color: #cfd8dc; -} -.tm-quark-field__input_size_medium:disabled::placeholder { - color: #cfd8dc; -} -.tm-quark-field__input_size_large { - font-size: 16px; - line-height: 24px; - height: 60px; - padding-top: 17px; - padding-bottom: 17px; -} -.tm-quark-field__input_size_large::-webkit-input-placeholder { - color: transparent; - -webkit-user-select: none; - user-select: none; -} -.tm-quark-field__input_size_large:-ms-input-placeholder { - color: transparent; - -ms-user-select: none; - user-select: none; -} -.tm-quark-field__input_size_large::placeholder { - color: transparent; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} -.tm-quark-field__input_size_large.tm-quark-field__input_filled.tm-quark-field__input_with-label { - padding-top: 26px; - padding-bottom: 10px; -} -.tm-quark-field__input_valid, -.tm-quark-field__input_invalid { - padding-right: 49px; -} -.tm-quark-field__input_valid { - -webkit-animation: TMQuarkInputMarkValid 1s cubic-bezier(0.645, 0.045, 0.355, 1); - animation: TMQuarkInputMarkValid 1s cubic-bezier(0.645, 0.045, 0.355, 1); -} -@-webkit-keyframes TMQuarkInputMarkValid { - 25%, - 75% { - background-color: #ddf7e5; - box-shadow: inset 0 1px 0 0 #a8e4bb; - border-color: transparent; - } -} -@keyframes TMQuarkInputMarkValid { - 25%, - 75% { - background-color: #ddf7e5; - box-shadow: inset 0 1px 0 0 #a8e4bb; - border-color: transparent; - } -} -.tm-quark-field__input_invalid { - -webkit-animation: TMQuarkInputMarkInvalid 1s cubic-bezier(0.645, 0.045, 0.355, 1); - animation: TMQuarkInputMarkInvalid 1s cubic-bezier(0.645, 0.045, 0.355, 1); -} -@-webkit-keyframes TMQuarkInputMarkInvalid { - 25%, - 75% { - background-color: #fff8e1; - box-shadow: inset 0 1px 0 0 #ffca28; - border-color: transparent; - } -} -@keyframes TMQuarkInputMarkInvalid { - 25%, - 75% { - background-color: #fff8e1; - box-shadow: inset 0 1px 0 0 #ffca28; - border-color: transparent; - } -} -.tm-quark-field__input:focus { - background-color: #fff; - border-color: #90caf9; - box-shadow: none; - outline: none; -} -.tm-quark-field__input:disabled { - background-color: #fff; - border-color: #eceff1; - box-shadow: none; - color: #cfd8dc; - cursor: not-allowed; -} -.tm-quark-field__icon { - height: 20px; - position: absolute; - top: 50%; - -webkit-transform: translateY(-50%); - transform: translateY(-50%); - width: 20px; -} -.tm-quark-field__icon::before { - background-position: center; - background-repeat: no-repeat; - content: ""; - height: 100%; - left: 50%; - position: absolute; - top: 50%; - -webkit-transform: translateX(-50%) translateY(-50%); - transform: translateX(-50%) translateY(-50%); - width: 100%; -} -.tm-quark-field__icon_type_field-type { - left: 20px; -} -.tm-quark-field__icon_type_validation-status { - -webkit-animation: TMQuarkInputShowValidationStatusIcon 0.25s cubic-bezier(0.645, 0.045, 0.355, 1); - animation: TMQuarkInputShowValidationStatusIcon 0.25s cubic-bezier(0.645, 0.045, 0.355, 1); - display: none; - right: 20px; -} -.tm-quark-field__input_valid ~ .tm-quark-field__icon_type_validation-status, -.tm-quark-field__input_invalid ~ .tm-quark-field__icon_type_validation-status { - display: block; -} -@-webkit-keyframes TMQuarkInputShowValidationStatusIcon { - from { - opacity: 0; - } - to { - opacity: 1; - } -} -@keyframes TMQuarkInputShowValidationStatusIcon { - from { - opacity: 0; - } - to { - opacity: 1; - } -} -.tm-quark-field__icon_type_field-type-toggle { - right: 20px; -} -.tm-quark-field__input_valid ~ .tm-quark-field__icon_type_field-type-toggle, -.tm-quark-field__input_invalid ~ .tm-quark-field__icon_type_field-type-toggle { - right: 50px; -} -.tm-quark-field__icon_check::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); -} -.tm-quark-field__icon_warning::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); -} -.tm-quark-field__icon_search::before, -.tm-quark-field__icon_maginifier::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); -} -.tm-quark-field__input:focus ~ .tm-quark-field__icon_search::before, -.tm-quark-field__input:focus ~ .tm-quark-field__icon_maginifier::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); -} -.tm-quark-field__icon_email::before, -.tm-quark-field__icon_letter::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); -} -.tm-quark-field__input:focus ~ .tm-quark-field__icon_email::before, -.tm-quark-field__input:focus ~ .tm-quark-field__icon_letter::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); -} -.tm-quark-field__icon_password::before, -.tm-quark-field__icon_key::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); -} -.tm-quark-field__input:focus ~ .tm-quark-field__icon_password::before, -.tm-quark-field__input:focus ~ .tm-quark-field__icon_key::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); -} -.tm-quark-field__icon_user::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); -} -.tm-quark-field__input:focus ~ .tm-quark-field__icon_user::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); -} -.tm-quark-field__icon_eye::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); -} -.tm-quark-field__icon_eye:active::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); -} -.tm-quark-field__label { - color: #90a4ae; - font-size: 16px; - line-height: 24px; - left: 20px; - pointer-events: none; - position: absolute; - top: 17px; - transition: all 0.45s cubic-bezier(0.23, 1, 0.32, 1); -} -.tm-quark-field__input_with-icon + .tm-quark-field__label { - left: 50px; -} -.tm-quark-field__input_empty:focus + .tm-quark-field__label { - color: #bbdefb; -} -.tm-quark-field__input_filled + .tm-quark-field__label { - font-size: 11px; - line-height: 16px; - color: #90a4ae; - top: 10px; -} -.tm-quark-field__input:disabled + .tm-quark-field__label { - color: #cfd8dc; -} -.loader { - box-sizing: border-box; - display: inline-block; - position: relative; - vertical-align: middle; - /* .loadre modes */ - /* .loader__line */ -} -.loader *, -.loader *::before, -.loader *::after { - box-sizing: border-box; -} -.loader_width_full { - width: 100%; -} -.loader_width_fixed { - width: 120px; -} -.loader_height_medium { - height: 4px; -} -.loader_height_large { - height: 8px; -} -.loader .loader__line { - -webkit-animation-name: loaderLineMove; - animation-name: loaderLineMove; - -webkit-animation-duration: 2s; - animation-duration: 2s; - -webkit-animation-iteration-count: infinite; - animation-iteration-count: infinite; - -webkit-animation-fill-mode: forwards; - animation-fill-mode: forwards; - background-color: #2196f3; - bottom: 0; - position: absolute; - top: 0; -} -.loader .loader__line:first-child { - -webkit-animation-delay: .2s; - animation-delay: .2s; - left: 0; - opacity: .25; - width: 25%; -} -.loader .loader__line:nth-child(2) { - -webkit-animation-delay: .1s; - animation-delay: .1s; - left: 0; - opacity: .5; - width: 25%; -} -.loader .loader__line:last-child { - left: 12.5%; - width: 12.5%; -} -@-webkit-keyframes loaderLineMove { - 50% { - left: 75%; - } -} -@keyframes loaderLineMove { - 50% { - left: 75%; - } -} -.popup { - box-sizing: border-box; - height: 100%; - left: 0; - position: fixed; - -webkit-text-size-adjust: 100%; - -ms-text-size-adjust: 100%; - top: 0; - width: 100%; - z-index: 9999; - overflow: auto; - line-height: 100vh; - text-align: center; -} -.popup *, -.popup *::before, -.popup *::after { - box-sizing: border-box; -} -.popup__bg { - background-color: #243238; - bottom: 0; - left: 0; - opacity: .95; - position: fixed; - right: 0; - top: 0; - z-index: 0; -} -.popup__content { - -webkit-animation-duration: .3s; - animation-duration: .3s; - -webkit-animation-fill-mode: forwards; - animation-fill-mode: forwards; - -webkit-animation-timing-function: cubic-bezier(0.86, 0, 0.07, 1); - animation-timing-function: cubic-bezier(0.86, 0, 0.07, 1); - border-radius: 3px; - display: inline-block; - position: relative; - z-index: 1; - line-height: 1; - vertical-align: middle; -} -.popup__content_padding_none.dropdown__content_bg_transparent { - padding: 40px; -} -.popup__content_padding_none.dropdown__content_bg_fill { - padding: 0; -} -.popup__content_padding_medium { - padding: 40px; -} -.popup__content_padding_large { - padding: 80px; -} -.popup__content_bg_transparent { - background-color: rgba(0, 0, 0, 0); - color: #fff; -} -.popup__content_bg_fill { - background-color: #fff; -} -.popup__content_bg_fill.popup__content_padding_none, -.popup__content_bg_fill.popup__content_padding_medium { - margin: 40px; - max-width: calc(100% - 80px); -} -.popup__content_bg_fill.popup__content_padding_large { - margin: 80px; - max-width: calc(100% - 160px); -} -.popup__content_animate_show { - -webkit-animation-name: showPopupContent; - animation-name: showPopupContent; -} -.popup__content_animate_hide { - -webkit-animation-name: hidePopupContent; - animation-name: hidePopupContent; -} -@-webkit-keyframes showPopupContent { - from { - opacity: 0; - -webkit-transform: scale(0.8); - transform: scale(0.8); - } - to { - opacity: 1; - -webkit-transform: scale(1); - transform: scale(1); - } -} -@keyframes showPopupContent { - from { - opacity: 0; - -webkit-transform: scale(0.8); - transform: scale(0.8); - } - to { - opacity: 1; - -webkit-transform: scale(1); - transform: scale(1); - } -} -@-webkit-keyframes hidePopupContent { - from { - opacity: 1; - -webkit-transform: scale(1); - transform: scale(1); - } - to { - opacity: 0; - -webkit-transform: scale(0.8); - transform: scale(0.8); - } -} -@keyframes hidePopupContent { - from { - opacity: 1; - -webkit-transform: scale(1); - transform: scale(1); - } - to { - opacity: 0; - -webkit-transform: scale(0.8); - transform: scale(0.8); - } -} -.popup__close-btn { - background: rgba(0, 0, 0, 0); - width: 40px; - height: 40px; - cursor: pointer; - position: absolute; - -webkit-text-decoration-skip: objects; - -webkit-text-size-adjust: 100%; - -ms-text-size-adjust: 100%; - z-index: 2; -} -.popup__close-btn::-moz-focus-inner { - border-style: none; - padding: 0; -} -.popup__close-btn_bg_fill { - right: -20px; - top: -20px; -} -.popup__close-btn_bg_transparent { - left: 100%; - top: 0; -} -.popup__close-cross { - position: absolute; - border-radius: 50%; - top: 50%; - left: 50%; - -webkit-transform: translate(-50%, -50%) rotate(45deg); - transform: translate(-50%, -50%) rotate(45deg); - z-index: 2; -} -.popup__close-cross::before, -.popup__close-cross::after { - content: ""; - position: absolute; - background-color: #fff; -} -.popup__close-cross_bg_fill { - background-color: #b0bec5; - height: 30px; - width: 30px; -} -.popup__close-cross_bg_fill::before { - width: 16px; - height: 4px; - left: 7px; - top: 13px; -} -.popup__close-cross_bg_fill::after { - width: 4px; - height: 16px; - left: 13px; - top: 7px; -} -.popup__close-btn:hover .popup__close-cross_bg_fill, -.popup__close-btn:focus .popup__close-cross_bg_fill { - background-color: #d84315; -} -.popup__close-cross_bg_transparent { - background-color: rgba(0, 0, 0, 0); - width: 26px; - height: 26px; -} -.popup__close-cross_bg_transparent::before, -.popup__close-cross_bg_transparent::after { - left: 50%; - top: 50%; - -webkit-transform: translate(-50%, -50%); - transform: translate(-50%, -50%); -} -.popup__close-btn:hover .popup__close-cross_bg_transparent::before, -.popup__close-btn:hover .popup__close-cross_bg_transparent::after, -.popup__close-btn:focus .popup__close-cross_bg_transparent::before, -.popup__close-btn:focus .popup__close-cross_bg_transparent::after { - background-color: #d84315; -} -.popup__close-cross_bg_transparent::before { - width: 100%; - height: 3px; -} -.popup__close-cross_bg_transparent::after { - width: 3px; - height: 100%; -} -.popup__close-text { - background-color: #546e7a; - border-radius: 3px; - color: #fff; - font-size: 13px; - height: 40px; - line-height: 40px; - opacity: 0; - padding: 0 20px; - position: absolute; - transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55); - transition-delay: .2s; - transition-duration: .5s; - transition-property: opacity, top, -webkit-transform; - transition-property: opacity, top, transform; - transition-property: opacity, top, transform, -webkit-transform; - z-index: 1; -} -.popup__close-text::before { - background-color: #546e7a; - border-top-right-radius: 3px; - content: ""; - height: 14px; - left: 50%; - margin-left: -7px; - position: absolute; - top: -7px; - -webkit-transform: rotate(-45deg); - transform: rotate(-45deg); - width: 14px; -} -.popup__close-btn_bg_transparent + .popup__close-text { - left: 100%; - top: 10px; - -webkit-transform: scale(0.8) translateX(-62%); - transform: scale(0.8) translateX(-62%); - margin-left: 20px; -} -.popup__close-btn_bg_fill + .popup__close-text { - left: 100%; - top: -5px; - -webkit-transform: scale(0.8) translateX(-62%); - transform: scale(0.8) translateX(-62%); -} -.popup__close-btn:hover + .popup__close-text { - opacity: 1; - -webkit-transform: scale(1) translateX(-50%); - transform: scale(1) translateX(-50%); -} -.popup__close-btn_bg_transparent:hover + .popup__close-text { - top: 50px; -} -.popup__close-btn_bg_fill:hover + .popup__close-text { - top: 35px; -} -.tm-quark-radio { - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; - box-sizing: border-box; - cursor: default; - display: -webkit-inline-box; - display: -ms-inline-flexbox; - display: inline-flex; - -webkit-box-orient: horizontal; - -webkit-box-direction: normal; - -ms-flex-flow: row nowrap; - flex-flow: row nowrap; - -ms-touch-action: manipulation; - touch-action: manipulation; - -webkit-text-size-adjust: 100%; - -ms-text-size-adjust: 100%; -} -.tm-quark-radio *, -.tm-quark-radio *::before, -.tm-quark-radio *::after { - box-sizing: inherit; -} -.tm-quark-radio:focus { - outline: none; -} -.tm-quark-radio__icon { - background-color: transparent; - border: 2px solid; - border-radius: 50%; - color: #cfd8dc; - height: 20px; - min-height: 20px; - min-width: 20px; - width: 20px; -} -.tm-quark-radio__label { - padding-left: 10px; -} -.tm-quark-radio__input { - display: none; -} -.tm-quark-radio__input:checked + .tm-quark-radio__icon { - color: #1ab744; -} -.tm-quark-radio__input:checked + .tm-quark-radio__icon::before { - border: 5px solid; - border-radius: 50%; - content: ""; - display: block; - height: 10px; - margin: 3px; - width: 10px; -} -.tm-quark-radio__input:checked ~ .tm-quark-radio__label { - color: #1ab744; - font-weight: 700; -} -.tm-quark-radio__input:disabled + .tm-quark-radio__icon, -.tm-quark-radio__input:disabled ~ .tm-quark-radio__label { - cursor: not-allowed; -} -.tm-quark-radio__input:disabled + .tm-quark-radio__icon { - color: #eceff1; -} -.tm-quark-radio__input:disabled:checked + .tm-quark-radio__icon { - color: #cfd8dc; -} -.tm-quark-radio__input:disabled ~ .tm-quark-radio__label { - color: #cfd8dc; -} -.tm-quark-radio__input:not(:disabled) + .tm-quark-radio__icon, -.tm-quark-radio__input:not(:disabled) ~ .tm-quark-radio__label { - cursor: pointer; -} -.tm-quark-radio:hover .tm-quark-radio__input:not(:disabled) + .tm-quark-radio__icon, -.tm-quark-radio:active .tm-quark-radio__input:not(:disabled) + .tm-quark-radio__icon { - color: #1ab744; -} -.tm-quark-radio:hover .tm-quark-radio__input:not(:disabled) ~ .tm-quark-radio__label, -.tm-quark-radio:active .tm-quark-radio__input:not(:disabled) ~ .tm-quark-radio__label { - color: #1ab744; -} -.tm-quark-radio:active .tm-quark-radio__input:not(:disabled) + .tm-quark-radio__icon { - background-color: #1ab744; - -webkit-transform: scale(0.8) translateY(2px); - transform: scale(0.8) translateY(2px); -} -.tm-quark-radio:active .tm-quark-radio__input:not(:disabled) ~ .tm-quark-radio__label { - -webkit-transform: translateY(1px); - transform: translateY(1px); -} -.tm-quark-slider { - box-sizing: border-box; - -webkit-box-align: start; - -ms-flex-align: start; - align-items: flex-start; - -webkit-box-orient: horizontal; - -webkit-box-direction: normal; - -ms-flex-flow: row wrap; - flex-flow: row wrap; - position: relative; - width: 100%; -} -.tm-quark-slider *, -.tm-quark-slider *::before, -.tm-quark-slider *::after { - box-sizing: inherit; -} -.tm-quark-slider_orientation_horizontal { - display: -webkit-box; - display: -ms-flexbox; - display: flex; -} -.tm-quark-slider_orientation_vertical { - display: -webkit-inline-box; - display: -ms-inline-flexbox; - display: inline-flex; -} -.tm-quark-slider__labels { - position: relative; -} -.tm-quark-slider__labels_orientation_horizontal { - height: 40px; - margin: 0 15px; - width: calc(100% - 30px); -} -.tm-quark-slider__labels_orientation_vertical { - height: calc(100% - 30px); - margin: 15px 0; -} -.tm-quark-slider__label { - position: absolute; - z-index: 1; -} -.tm-quark-slider__label_orientation_horizontal { - line-height: 30px; - top: 0; - -webkit-transform: translateX(-50%); - transform: translateX(-50%); -} -.tm-quark-slider__label_orientation_horizontal.tm-quark-slider__label_value_intermediate { - padding: 0 5px; -} -.tm-quark-slider__label_orientation_horizontal.tm-quark-slider__label_value_intermediate::before { - left: 50%; - top: 55px; -} -.tm-quark-slider__label_orientation_vertical { - line-height: 1; - right: 10px; - -webkit-transform: translateY(50%); - transform: translateY(50%); -} -.tm-quark-slider__label_orientation_vertical.tm-quark-slider__label_value_intermediate { - padding: 5px 0; -} -.tm-quark-slider__label_orientation_vertical.tm-quark-slider__label_value_intermediate::before { - right: -30px; - top: 50%; -} -.tm-quark-slider__label_value_intermediate { - font-size: 16px; - transition: color 0.3s cubic-bezier(0.86, 0, 0.07, 1); -} -.tm-quark-slider__label_value_intermediate::before { - content: ""; - background-color: #42a5f5; - border-radius: 50%; - height: 5px; - position: absolute; - -webkit-transform: translateX(-50%) translateY(-50%); - transform: translateX(-50%) translateY(-50%); - transition: background-color 0.3s cubic-bezier(0.86, 0, 0.07, 1); - width: 5px; -} -.tm-quark-slider__label_value_current { - color: #1ab744; - font-size: 20px; - font-weight: 700; -} -.tm-quark-slider__label_hidden { - color: transparent; -} -.tm-quark-slider__label_hidden::before { - background-color: transparent; -} -.tm-quark-slider__range { - position: relative; -} -.tm-quark-slider__range_orientation_horizontal { - height: 30px; - margin: 0 15px; - width: calc(100% - 30px); -} -.tm-quark-slider__range_orientation_vertical { - height: calc(100% - 30px); - margin: 15px 0; - width: 30px; -} -.tm-quark-slider__input { - -webkit-appearance: none; - background: transparent; - border: 0; - cursor: pointer; - margin: 0; - opacity: 0; - position: relative; - z-index: 2; -} -.tm-quark-slider__input_orientation_horizontal { - -webkit-appearance: none; - height: 30px; - margin-left: -15px; - padding: 0; - width: calc(100% + 30px); -} -.tm-quark-slider__input_orientation_horizontal::-webkit-slider-runnable-track { - height: 30px; -} -.tm-quark-slider__input_orientation_horizontal::-moz-range-track { - height: 30px; -} -.tm-quark-slider__input_orientation_horizontal::-ms-track { - border: 0; - height: 30px; -} -.tm-quark-slider__input_orientation_vertical { - -webkit-appearance: slider-vertical; - height: calc(100% + 30px); - margin-top: -15px; - padding: 0 49px 0 15px; - width: 30px; - -webkit-writing-mode: bt-lr; - -ms-writing-mode: bt-lr; - writing-mode: bt-lr; -} -.tm-quark-slider__input_orientation_vertical::-webkit-slider-runnable-track { - width: 30px; -} -.tm-quark-slider__input_orientation_vertical::-moz-range-track { - width: 30px; -} -.tm-quark-slider__input_orientation_vertical::-ms-track { - border: 0; - height: 100%; - width: 30px; -} -.tm-quark-slider__input::-webkit-slider-thumb { - -webkit-appearance: none; - border-radius: 50%; - height: 30px; - min-height: 30px; - min-width: 30px; - width: 30px; -} -.tm-quark-slider__input::-moz-range-thumb { - border: 0; - border-radius: 50%; - height: 30px; - width: 30px; -} -.tm-quark-slider__input::-ms-thumb { - border: 0; - border-radius: 50%; - height: 30px; - width: 30px; -} -.tm-quark-slider__input::-ms-tooltip { - display: none; -} -.tm-quark-slider__input:focus { - outline: none; -} -.tm-quark-slider__input:disabled { - cursor: default; -} -.tm-quark-slider__thumb { - background: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+Cjxzdmcgd2lkdGg9IjEwcHgiIGhlaWdodD0iMTBweCIgdmlld0JveD0iMCAwIDEwIDEwIiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPgogICAgPCEtLSBHZW5lcmF0b3I6IFNrZXRjaCAzLjguMyAoMjk4MDIpIC0gaHR0cDovL3d3dy5ib2hlbWlhbmNvZGluZy5jb20vc2tldGNoIC0tPgogICAgPHRpdGxlPmxpbmVzPC90aXRsZT4KICAgIDxkZXNjPkNyZWF0ZWQgd2l0aCBTa2V0Y2guPC9kZXNjPgogICAgPGRlZnM+PC9kZWZzPgogICAgPGcgaWQ9IlBhZ2UtMSIgc3Ryb2tlPSJub25lIiBzdHJva2Utd2lkdGg9IjEiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICAgICAgPGcgaWQ9IlNsaWRlcnMiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC01ODkuMDAwMDAwLCAtNDM1LjAwMDAwMCkiIGZpbGw9IiNGRkZGRkYiPgogICAgICAgICAgICA8ZyBpZD0iU0xJREVSMSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoNDAuMDAwMDAwLCAzOTAuMDAwMDAwKSI+CiAgICAgICAgICAgICAgICA8ZyBpZD0iY2xpY2tlZCIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoNTM2LjAwMDAwMCwgMC4wMDAwMDApIj4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMTMsNDUuNTA5NjQ5NSBDMTMsNDUuMjI4MTc3OSAxMy4yMzE5MzM2LDQ1IDEzLjUsNDUgQzEzLjc3NjE0MjQsNDUgMTQsNDUuMjI3NjUyOCAxNCw0NS41MDk2NDk1IEwxNCw1NC40OTAzNTA1IEMxNCw1NC43NzE4MjIxIDEzLjc2ODA2NjQsNTUgMTMuNSw1NSBDMTMuMjIzODU3Niw1NSAxMyw1NC43NzIzNDcyIDEzLDU0LjQ5MDM1MDUgTDEzLDQ1LjUwOTY0OTUgWiBNMTYsNDUuNTA5NjQ5NSBDMTYsNDUuMjI4MTc3OSAxNi4yMzE5MzM2LDQ1IDE2LjUsNDUgQzE2Ljc3NjE0MjQsNDUgMTcsNDUuMjI3NjUyOCAxNyw0NS41MDk2NDk1IEwxNyw1NC40OTAzNTA1IEMxNyw1NC43NzE4MjIxIDE2Ljc2ODA2NjQsNTUgMTYuNSw1NSBDMTYuMjIzODU3Niw1NSAxNiw1NC43NzIzNDcyIDE2LDU0LjQ5MDM1MDUgTDE2LDQ1LjUwOTY0OTUgWiBNMTksNDUuNTA5NjQ5NSBDMTksNDUuMjI4MTc3OSAxOS4yMzE5MzM2LDQ1IDE5LjUsNDUgQzE5Ljc3NjE0MjQsNDUgMjAsNDUuMjI3NjUyOCAyMCw0NS41MDk2NDk1IEwyMCw1NC40OTAzNTA1IEMyMCw1NC43NzE4MjIxIDE5Ljc2ODA2NjQsNTUgMTkuNSw1NSBDMTkuMjIzODU3Niw1NSAxOSw1NC43NzIzNDcyIDE5LDU0LjQ5MDM1MDUgTDE5LDQ1LjUwOTY0OTUgWiBNMjIsNDUuNTA5NjQ5NSBDMjIsNDUuMjI4MTc3OSAyMi4yMzE5MzM2LDQ1IDIyLjUsNDUgQzIyLjc3NjE0MjQsNDUgMjMsNDUuMjI3NjUyOCAyMyw0NS41MDk2NDk1IEwyMyw1NC40OTAzNTA1IEMyMyw1NC43NzE4MjIxIDIyLjc2ODA2NjQsNTUgMjIuNSw1NSBDMjIuMjIzODU3Niw1NSAyMiw1NC43NzIzNDcyIDIyLDU0LjQ5MDM1MDUgTDIyLDQ1LjUwOTY0OTUgWiIgaWQ9ImxpbmVzIj48L3BhdGg+CiAgICAgICAgICAgICAgICA8L2c+CiAgICAgICAgICAgIDwvZz4KICAgICAgICA8L2c+CiAgICA8L2c+Cjwvc3ZnPg==") no-repeat center, linear-gradient(to bottom, #42a5f5 0%, #2196f3 100%); - border-radius: 50%; - cursor: pointer; - height: 30px; - position: absolute; - width: 30px; - z-index: 2; -} -.tm-quark-slider__thumb_orientation_horizontal { - bottom: 0; - -webkit-transform: translateX(-50%); - transform: translateX(-50%); -} -.tm-quark-slider__thumb_orientation_vertical { - right: 0; - -webkit-transform: translateY(50%); - transform: translateY(50%); -} -.tm-quark-slider__thumb_hovered { - background: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+Cjxzdmcgd2lkdGg9IjEwcHgiIGhlaWdodD0iMTBweCIgdmlld0JveD0iMCAwIDEwIDEwIiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPgogICAgPCEtLSBHZW5lcmF0b3I6IFNrZXRjaCAzLjguMyAoMjk4MDIpIC0gaHR0cDovL3d3dy5ib2hlbWlhbmNvZGluZy5jb20vc2tldGNoIC0tPgogICAgPHRpdGxlPmxpbmVzPC90aXRsZT4KICAgIDxkZXNjPkNyZWF0ZWQgd2l0aCBTa2V0Y2guPC9kZXNjPgogICAgPGRlZnM+PC9kZWZzPgogICAgPGcgaWQ9IlBhZ2UtMSIgc3Ryb2tlPSJub25lIiBzdHJva2Utd2lkdGg9IjEiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICAgICAgPGcgaWQ9IlNsaWRlcnMiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC01ODkuMDAwMDAwLCAtNDM1LjAwMDAwMCkiIGZpbGw9IiNGRkZGRkYiPgogICAgICAgICAgICA8ZyBpZD0iU0xJREVSMSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoNDAuMDAwMDAwLCAzOTAuMDAwMDAwKSI+CiAgICAgICAgICAgICAgICA8ZyBpZD0iY2xpY2tlZCIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoNTM2LjAwMDAwMCwgMC4wMDAwMDApIj4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMTMsNDUuNTA5NjQ5NSBDMTMsNDUuMjI4MTc3OSAxMy4yMzE5MzM2LDQ1IDEzLjUsNDUgQzEzLjc3NjE0MjQsNDUgMTQsNDUuMjI3NjUyOCAxNCw0NS41MDk2NDk1IEwxNCw1NC40OTAzNTA1IEMxNCw1NC43NzE4MjIxIDEzLjc2ODA2NjQsNTUgMTMuNSw1NSBDMTMuMjIzODU3Niw1NSAxMyw1NC43NzIzNDcyIDEzLDU0LjQ5MDM1MDUgTDEzLDQ1LjUwOTY0OTUgWiBNMTYsNDUuNTA5NjQ5NSBDMTYsNDUuMjI4MTc3OSAxNi4yMzE5MzM2LDQ1IDE2LjUsNDUgQzE2Ljc3NjE0MjQsNDUgMTcsNDUuMjI3NjUyOCAxNyw0NS41MDk2NDk1IEwxNyw1NC40OTAzNTA1IEMxNyw1NC43NzE4MjIxIDE2Ljc2ODA2NjQsNTUgMTYuNSw1NSBDMTYuMjIzODU3Niw1NSAxNiw1NC43NzIzNDcyIDE2LDU0LjQ5MDM1MDUgTDE2LDQ1LjUwOTY0OTUgWiBNMTksNDUuNTA5NjQ5NSBDMTksNDUuMjI4MTc3OSAxOS4yMzE5MzM2LDQ1IDE5LjUsNDUgQzE5Ljc3NjE0MjQsNDUgMjAsNDUuMjI3NjUyOCAyMCw0NS41MDk2NDk1IEwyMCw1NC40OTAzNTA1IEMyMCw1NC43NzE4MjIxIDE5Ljc2ODA2NjQsNTUgMTkuNSw1NSBDMTkuMjIzODU3Niw1NSAxOSw1NC43NzIzNDcyIDE5LDU0LjQ5MDM1MDUgTDE5LDQ1LjUwOTY0OTUgWiBNMjIsNDUuNTA5NjQ5NSBDMjIsNDUuMjI4MTc3OSAyMi4yMzE5MzM2LDQ1IDIyLjUsNDUgQzIyLjc3NjE0MjQsNDUgMjMsNDUuMjI3NjUyOCAyMyw0NS41MDk2NDk1IEwyMyw1NC40OTAzNTA1IEMyMyw1NC43NzE4MjIxIDIyLjc2ODA2NjQsNTUgMjIuNSw1NSBDMjIuMjIzODU3Niw1NSAyMiw1NC43NzIzNDcyIDIyLDU0LjQ5MDM1MDUgTDIyLDQ1LjUwOTY0OTUgWiIgaWQ9ImxpbmVzIj48L3BhdGg+CiAgICAgICAgICAgICAgICA8L2c+CiAgICAgICAgICAgIDwvZz4KICAgICAgICA8L2c+CiAgICA8L2c+Cjwvc3ZnPg==") no-repeat center, linear-gradient(to bottom, #2196f3 0%, #1976d2 100%); - z-index: 1; -} -.tm-quark-slider__input:active + .tm-quark-slider__thumb { - background: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+Cjxzdmcgd2lkdGg9IjEwcHgiIGhlaWdodD0iMTBweCIgdmlld0JveD0iMCAwIDEwIDEwIiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPgogICAgPCEtLSBHZW5lcmF0b3I6IFNrZXRjaCAzLjguMyAoMjk4MDIpIC0gaHR0cDovL3d3dy5ib2hlbWlhbmNvZGluZy5jb20vc2tldGNoIC0tPgogICAgPHRpdGxlPmxpbmVzPC90aXRsZT4KICAgIDxkZXNjPkNyZWF0ZWQgd2l0aCBTa2V0Y2guPC9kZXNjPgogICAgPGRlZnM+PC9kZWZzPgogICAgPGcgaWQ9IlBhZ2UtMSIgc3Ryb2tlPSJub25lIiBzdHJva2Utd2lkdGg9IjEiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICAgICAgPGcgaWQ9IlNsaWRlcnMiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC01ODkuMDAwMDAwLCAtNDM1LjAwMDAwMCkiIGZpbGw9IiNGRkZGRkYiPgogICAgICAgICAgICA8ZyBpZD0iU0xJREVSMSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoNDAuMDAwMDAwLCAzOTAuMDAwMDAwKSI+CiAgICAgICAgICAgICAgICA8ZyBpZD0iY2xpY2tlZCIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoNTM2LjAwMDAwMCwgMC4wMDAwMDApIj4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMTMsNDUuNTA5NjQ5NSBDMTMsNDUuMjI4MTc3OSAxMy4yMzE5MzM2LDQ1IDEzLjUsNDUgQzEzLjc3NjE0MjQsNDUgMTQsNDUuMjI3NjUyOCAxNCw0NS41MDk2NDk1IEwxNCw1NC40OTAzNTA1IEMxNCw1NC43NzE4MjIxIDEzLjc2ODA2NjQsNTUgMTMuNSw1NSBDMTMuMjIzODU3Niw1NSAxMyw1NC43NzIzNDcyIDEzLDU0LjQ5MDM1MDUgTDEzLDQ1LjUwOTY0OTUgWiBNMTYsNDUuNTA5NjQ5NSBDMTYsNDUuMjI4MTc3OSAxNi4yMzE5MzM2LDQ1IDE2LjUsNDUgQzE2Ljc3NjE0MjQsNDUgMTcsNDUuMjI3NjUyOCAxNyw0NS41MDk2NDk1IEwxNyw1NC40OTAzNTA1IEMxNyw1NC43NzE4MjIxIDE2Ljc2ODA2NjQsNTUgMTYuNSw1NSBDMTYuMjIzODU3Niw1NSAxNiw1NC43NzIzNDcyIDE2LDU0LjQ5MDM1MDUgTDE2LDQ1LjUwOTY0OTUgWiBNMTksNDUuNTA5NjQ5NSBDMTksNDUuMjI4MTc3OSAxOS4yMzE5MzM2LDQ1IDE5LjUsNDUgQzE5Ljc3NjE0MjQsNDUgMjAsNDUuMjI3NjUyOCAyMCw0NS41MDk2NDk1IEwyMCw1NC40OTAzNTA1IEMyMCw1NC43NzE4MjIxIDE5Ljc2ODA2NjQsNTUgMTkuNSw1NSBDMTkuMjIzODU3Niw1NSAxOSw1NC43NzIzNDcyIDE5LDU0LjQ5MDM1MDUgTDE5LDQ1LjUwOTY0OTUgWiBNMjIsNDUuNTA5NjQ5NSBDMjIsNDUuMjI4MTc3OSAyMi4yMzE5MzM2LDQ1IDIyLjUsNDUgQzIyLjc3NjE0MjQsNDUgMjMsNDUuMjI3NjUyOCAyMyw0NS41MDk2NDk1IEwyMyw1NC40OTAzNTA1IEMyMyw1NC43NzE4MjIxIDIyLjc2ODA2NjQsNTUgMjIuNSw1NSBDMjIuMjIzODU3Niw1NSAyMiw1NC43NzIzNDcyIDIyLDU0LjQ5MDM1MDUgTDIyLDQ1LjUwOTY0OTUgWiIgaWQ9ImxpbmVzIj48L3BhdGg+CiAgICAgICAgICAgICAgICA8L2c+CiAgICAgICAgICAgIDwvZz4KICAgICAgICA8L2c+CiAgICA8L2c+Cjwvc3ZnPg==") no-repeat 10px 11px, linear-gradient(to bottom, #0d47a1 0%, #1976d2 100%); - z-index: 1; -} -.tm-quark-slider__input:disabled + .tm-quark-slider__thumb { - background: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAiIGhlaWdodD0iMTAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiA8IS0tIEdlbmVyYXRvcjogU2tldGNoIDMuOC4zICgyOTgwMikgLSBodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2ggLS0+CiA8dGl0bGU+bGluZXM8L3RpdGxlPgogPGRlc2M+Q3JlYXRlZCB3aXRoIFNrZXRjaC48L2Rlc2M+CgogPGc+CiAgPHRpdGxlPmJhY2tncm91bmQ8L3RpdGxlPgogIDxyZWN0IGZpbGw9Im5vbmUiIGlkPSJjYW52YXNfYmFja2dyb3VuZCIgaGVpZ2h0PSI0MDIiIHdpZHRoPSI1ODIiIHk9Ii0xIiB4PSItMSIvPgogPC9nPgogPGc+CiAgPHRpdGxlPkxheWVyIDE8L3RpdGxlPgogIDxnIGZpbGwtcnVsZT0iZXZlbm9kZCIgZmlsbD0ibm9uZSIgaWQ9IlBhZ2UtMSI+CiAgIDxnIGZpbGw9IiNGRkZGRkYiIGlkPSJTbGlkZXJzIj4KICAgIDxnIGlkPSJTTElERVIxIj4KICAgICA8ZyBpZD0iY2xpY2tlZCI+CiAgICAgIDxwYXRoIGZpbGw9IiNkZGUzZTYiIGlkPSJsaW5lcyIgZD0ibTAsMC41MDk2NWMwLC0wLjI4MTQ3IDAuMjMxOTMsLTAuNTA5NjUgMC41LC0wLjUwOTY1YzAuMjc2MTQsMCAwLjUsMC4yMjc2NSAwLjUsMC41MDk2NWwwLDguOTgwN2MwLDAuMjgxNDcgLTAuMjMxOTMsMC41MDk2NSAtMC41LDAuNTA5NjVjLTAuMjc2MTQsMCAtMC41LC0wLjIyNzY1IC0wLjUsLTAuNTA5NjVsMCwtOC45ODA3em0zLDBjMCwtMC4yODE0NyAwLjIzMTkzLC0wLjUwOTY1IDAuNSwtMC41MDk2NWMwLjI3NjE0LDAgMC41LDAuMjI3NjUgMC41LDAuNTA5NjVsMCw4Ljk4MDdjMCwwLjI4MTQ3IC0wLjIzMTkzLDAuNTA5NjUgLTAuNSwwLjUwOTY1Yy0wLjI3NjE0LDAgLTAuNSwtMC4yMjc2NSAtMC41LC0wLjUwOTY1bDAsLTguOTgwN3ptMywwYzAsLTAuMjgxNDcgMC4yMzE5MywtMC41MDk2NSAwLjUsLTAuNTA5NjVjMC4yNzYxNCwwIDAuNSwwLjIyNzY1IDAuNSwwLjUwOTY1bDAsOC45ODA3YzAsMC4yODE0NyAtMC4yMzE5MywwLjUwOTY1IC0wLjUsMC41MDk2NWMtMC4yNzYxNCwwIC0wLjUsLTAuMjI3NjUgLTAuNSwtMC41MDk2NWwwLC04Ljk4MDd6bTMsMGMwLC0wLjI4MTQ3IDAuMjMxOTMsLTAuNTA5NjUgMC41LC0wLjUwOTY1YzAuMjc2MTQsMCAwLjUsMC4yMjc2NSAwLjUsMC41MDk2NWwwLDguOTgwN2MwLDAuMjgxNDcgLTAuMjMxOTMsMC41MDk2NSAtMC41LDAuNTA5NjVjLTAuMjc2MTQsMCAtMC41LC0wLjIyNzY1IC0wLjUsLTAuNTA5NjVsMCwtOC45ODA3eiIvPgogICAgIDwvZz4KICAgIDwvZz4KICAgPC9nPgogIDwvZz4KIDwvZz4KPC9zdmc+") no-repeat center, #fff; - border: 2px solid #dde3e6; - cursor: default; - z-index: 1; -} -.tm-quark-slider__track { - background: linear-gradient(to bottom, #dde3e6 0%, #eceff1 100%); - border-radius: 3px; - position: absolute; -} -.tm-quark-slider__track_orientation_horizontal { - bottom: 15px; - height: 5px; - left: 50%; - -webkit-transform: translateX(-50%) translateY(50%); - transform: translateX(-50%) translateY(50%); - width: calc(100% - 30px); -} -.tm-quark-slider__track_orientation_vertical { - top: 50%; - height: calc(100% - 30px); - right: 15px; - -webkit-transform: translateX(50%) translateY(-50%); - transform: translateX(50%) translateY(-50%); - width: 5px; -} -.tm-quark-steps { - box-sizing: border-box; - display: -webkit-box; - display: -ms-flexbox; - display: flex; - -webkit-box-orient: horizontal; - -webkit-box-direction: normal; - -ms-flex-flow: row wrap; - flex-flow: row wrap; - -webkit-box-pack: justify; - -ms-flex-pack: justify; - justify-content: space-between; - width: 100%; -} -.tm-quark-steps *, -.tm-quark-steps *::before, -.tm-quark-steps *::after { - box-sizing: inherit; -} -.tm-quark-steps__label { - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; - background-color: transparent; - display: -webkit-box; - display: -ms-flexbox; - display: flex; - -webkit-box-orient: horizontal; - -webkit-box-direction: normal; - -ms-flex-flow: row nowrap; - flex-flow: row nowrap; - -ms-touch-action: manipulation; - touch-action: manipulation; -} -.tm-quark-steps__label:not(:last-of-type) { - -webkit-box-flex: 1; - -ms-flex-positive: 1; - flex-grow: 1; -} -.tm-quark-steps__label:not(:last-of-type).tm-quark-steps__label_with-title { - padding-right: 20px; -} -.tm-quark-steps__label:not(:last-of-type).tm-quark-steps__label_without-title { - padding-right: 40px; -} -.tm-quark-steps__label:not(:last-of-type).tm-quark-steps__label_without-title:after { - content: ""; - -webkit-box-flex: 1; - -ms-flex-positive: 1; - flex-grow: 1; - height: 4px; - background-image: url("data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQiIHdpZHRoPSI2IiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPg0KICA8cG9seWxpbmUgcG9pbnRzPSIwIDAgNiAwIiBmaWxsPSJub25lIiBzdHJva2Utd2lkdGg9IjAiLz4NCiAgPHBhdGggZD0iTTAgMEwwIDQgNCAyWiIgZmlsbD0iIzIxOTZGMyIvPg0KPC9zdmc+DQo="); - margin-left: 40px; -} -.tm-quark-steps__toggle-btn { - display: -webkit-inline-box; - display: -ms-inline-flexbox; - display: inline-flex; - cursor: pointer; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; - -webkit-box-orient: horizontal; - -webkit-box-direction: normal; - -ms-flex-flow: row wrap; - flex-flow: row wrap; - font-weight: 700; - font-size: 16px; - text-align: center; -} -.tm-quark-steps__toggle-btn::before { - content: attr(data-step-number); - color: #fff; - background-clip: padding-box; - border: 5px solid; - border-radius: 50%; - font-size: 16px; - font-weight: 700; - line-height: 30px; - height: 40px; - margin-right: 10px; - width: 40px; -} -.tm-quark-steps__toggle-btn_passed { - color: #2196f3; -} -.tm-quark-steps__toggle-btn_passed::before { - background-color: #2196f3; - border-color: rgba(33, 150, 243, 0.4); -} -.tm-quark-steps__toggle-btn_passed:hover::before { - background: linear-gradient(to bottom, #002196 0%, #1976d2 100%); - border: 0; - line-height: 40px; - transition: background cubic-bezier(0.86, 0, 0.07, 1) 0.3s, -webkit-transform cubic-bezier(0.86, 0, 0.07, 1) 0.3s; - transition: background cubic-bezier(0.86, 0, 0.07, 1) 0.3s, transform cubic-bezier(0.86, 0, 0.07, 1) 0.3s; - transition: background cubic-bezier(0.86, 0, 0.07, 1) 0.3s, transform cubic-bezier(0.86, 0, 0.07, 1) 0.3s, -webkit-transform cubic-bezier(0.86, 0, 0.07, 1) 0.3s; -} -.tm-quark-steps__toggle-btn_passed:active::before { - background: linear-gradient(to bottom, #0d47a1 0%, #1976d2 100%); - border: 0; - line-height: 40px; - -webkit-transform: scale(0.8); - transform: scale(0.8); - transition: background cubic-bezier(0.86, 0, 0.07, 1) 0.3s, -webkit-transform cubic-bezier(0.86, 0, 0.07, 1) 0.3s; - transition: background cubic-bezier(0.86, 0, 0.07, 1) 0.3s, transform cubic-bezier(0.86, 0, 0.07, 1) 0.3s; - transition: background cubic-bezier(0.86, 0, 0.07, 1) 0.3s, transform cubic-bezier(0.86, 0, 0.07, 1) 0.3s, -webkit-transform cubic-bezier(0.86, 0, 0.07, 1) 0.3s; -} -.tm-quark-steps__toggle-btn_active { - color: #243238; - cursor: default; -} -.tm-quark-steps__toggle-btn_active::before { - background-color: #243238; - border-color: rgba(96, 125, 139, 0.4); -} -.tm-quark-steps__toggle-btn_upcoming { - color: #b0bec5; - cursor: default; -} -.tm-quark-steps__toggle-btn_upcoming::before { - background-color: #b0bec5; - border-color: rgba(176, 190, 197, 0.4); -} -.tm-quark-steps__toggle-btn_disabled { - color: #dde3e6; - cursor: default; -} -.tm-quark-steps__toggle-btn_disabled::before { - border-color: rgba(176, 190, 197, 0.4); - color: #dde3e6; -} -.tm-quark-steps__toggle-btn:empty::before { - margin-right: 0; -} -.tm-quark-steps__toggle-btn:focus { - outline: none; -} -.tm-quark-steps__step-content { - width: 100%; -} -.switcher { - box-sizing: border-box; - display: inline-block; - -webkit-box-flex: 1; - -ms-flex-positive: 1; - flex-grow: 1; - position: relative; - text-align: center; - -webkit-text-size-adjust: 100%; - -ms-text-size-adjust: 100%; -} -.switcher *, -.switcher *::before, -.switcher *::after { - box-sizing: border-box; -} -.switcher__input { - height: 0; - left: 0; - margin: 0; - opacity: 0; - padding: 0; - position: absolute; - top: 0; - width: 0; -} -.switcher__label { - background-color: #dde3e6; - cursor: pointer; - display: inline-block; - font-weight: 400; - margin-bottom: 0; - -ms-touch-action: manipulation; - touch-action: manipulation; - vertical-align: top; - width: 100%; -} -.switcher_size_medium .switcher__label { - height: 40px; - padding: 10px 20px; -} -.switcher_size_large .switcher__label { - height: 60px; - padding: 20px 30px; -} -.switcher__label:before, -.switcher__label:after { - border-radius: 50%; - content: ""; - display: inline-block; - vertical-align: top; -} -.switcher__label:before { - border: 2px solid #cfd8dc; - height: 20px; - margin-right: 10px; - width: 20px; -} -:not(:checked) + .switcher__label:hover, -:not(:checked) + .switcher__label:focus, -:not(:checked) + .switcher__label:active { - color: #fff; -} -:not(:checked) + .switcher__label:hover:before, -:not(:checked) + .switcher__label:focus:before, -:not(:checked) + .switcher__label:active:before { - border-color: #fff; -} -:not(:checked) + .switcher__label:hover { - background-color: #2196f3; -} -:not(:checked) + .switcher__label:focus, -:not(:checked) + .switcher__label:active { - background-color: #1976d2; -} -.switcher_size_medium :not(:checked) + .switcher__label:focus, -.switcher_size_medium :not(:checked) + .switcher__label:active { - padding: 11px 20px 9px; -} -.switcher_size_large :not(:checked) + .switcher__label:focus, -.switcher_size_large :not(:checked) + .switcher__label:active { - padding: 21px 30px 19px; -} -:not(:checked) + .switcher__label:focus:before, -:not(:checked) + .switcher__label:active:before { - background-color: #fff; - border-color: #fff; - height: 16px; - margin: 3px 12px 0 2px; - width: 16px; -} -:checked + .switcher__label { - background-color: #fff; - color: #1ab744; - font-weight: 700; -} -:checked + .switcher__label:before { - background: radial-gradient(circle, #1ab744 5px, rgba(0, 0, 0, 0) 5px); - border-color: #1ab744; -} -:disabled + .switcher__label { - color: #b0bec5; - cursor: default; - pointer-events: none; -} -:disabled + .switcher__label:before { - border-color: #cfd8dc; -} -:disabled:checked + .switcher__label { - background-color: #fff; - color: #90a4ae; -} -:disabled:checked + .switcher__label:before { - background: radial-gradient(circle, #90a4ae 5px, rgba(0, 0, 0, 0) 5px); - border-color: #90a4ae; -} -.switcher-group { - box-sizing: border-box; - display: -webkit-box; - display: -ms-flexbox; - display: flex; - -webkit-box-pack: justify; - -ms-flex-pack: justify; - justify-content: space-between; - -webkit-text-size-adjust: 100%; - -ms-text-size-adjust: 100%; -} -.tm-quark-textarea { - box-sizing: border-box; - display: -webkit-box; - display: -ms-flexbox; - display: flex; - position: relative; - width: 100%; -} -.tm-quark-textarea *, -.tm-quark-textarea *::before, -.tm-quark-textarea *::after { - box-sizing: inherit; -} -.tm-quark-textarea__inner { - overflow: hidden; - width: 100%; -} -.tm-quark-textarea__input { - border: 0; - background-color: transparent; - border-radius: 0; - color: #243238; - display: -webkit-box; - display: -ms-flexbox; - display: flex; - height: auto; - margin: 22px 0 34px; - padding: 0 67px 0 20px; - -ms-touch-action: manipulation; - touch-action: manipulation; - overflow: auto; - position: relative; - resize: none; - min-width: calc(100% + 17px); - z-index: 1; -} -.tm-quark-textarea__input_with-icon { - padding-left: 50px; -} -.tm-quark-textarea__input_filled { - margin-bottom: 20px; - margin-top: 36px; -} -.tm-quark-textarea__input_size_medium { - font-size: 14px; - line-height: 21px; - max-height: 315px; - min-height: 63px; -} -.tm-quark-textarea__input_size_large { - font-size: 16px; - line-height: 24px; - max-height: 360px; - min-height: 72px; -} -.tm-quark-textarea__input:focus { - outline: none; -} -.tm-quark-textarea__input:disabled { - color: #cfd8dc; - cursor: not-allowed; -} -.tm-quark-textarea__input::-webkit-input-placeholder { - color: transparent; -} -.tm-quark-textarea__input:-ms-input-placeholder { - color: transparent; -} -.tm-quark-textarea__input::placeholder { - color: transparent; -} -.tm-quark-textarea__label { - background-color: #eceff1; - border: 1px solid transparent; - box-shadow: inset 0 1px 0 0 #cfd8dc; - border-radius: 3px; - color: #90a4ae; - cursor: text; - font-size: 16px; - height: 100%; - line-height: 24px; - padding: 19px 49px 19px 19px; - top: 0; - left: 0; - position: absolute; - transition: font-size 0.45s cubic-bezier(0.23, 1, 0.32, 1), line-height 0.45s cubic-bezier(0.23, 1, 0.32, 1); - width: 100%; -} -.tm-quark-textarea__input_with-icon + .tm-quark-textarea__label { - padding-left: 49px; -} -.tm-quark-textarea__input_filled + .tm-quark-textarea__label { - font-size: 11px; - line-height: 16px; -} -.tm-quark-textarea__input:disabled + .tm-quark-textarea__label { - background-color: #fff; - border-color: #eceff1; - box-shadow: none; - color: #cfd8dc; - cursor: not-allowed; -} -.tm-quark-textarea__input_valid + .tm-quark-textarea__label { - -webkit-animation: TMQuarkTextareaMarkValid 1s cubic-bezier(0.645, 0.045, 0.355, 1); - animation: TMQuarkTextareaMarkValid 1s cubic-bezier(0.645, 0.045, 0.355, 1); -} -@-webkit-keyframes TMQuarkTextareaMarkValid { - 25%, - 75% { - background-color: #ddf7e5; - box-shadow: inset 0 1px 0 0 #a8e4bb; - border-color: transparent; - } -} -@keyframes TMQuarkTextareaMarkValid { - 25%, - 75% { - background-color: #ddf7e5; - box-shadow: inset 0 1px 0 0 #a8e4bb; - border-color: transparent; - } -} -.tm-quark-textarea__input_invalid + .tm-quark-textarea__label { - -webkit-animation: TMQuarkTextareaMarkInvalid 1s cubic-bezier(0.645, 0.045, 0.355, 1); - animation: TMQuarkTextareaMarkInvalid 1s cubic-bezier(0.645, 0.045, 0.355, 1); -} -@-webkit-keyframes TMQuarkTextareaMarkInvalid { - 25%, - 75% { - background-color: #fff8e1; - box-shadow: inset 0 1px 0 0 #ffca28; - border-color: transparent; - } -} -@keyframes TMQuarkTextareaMarkInvalid { - 25%, - 75% { - background-color: #fff8e1; - box-shadow: inset 0 1px 0 0 #ffca28; - border-color: transparent; - } -} -.tm-quark-textarea__input:focus + .tm-quark-textarea__label { - background-color: #fff; - border-color: #90caf9; - box-shadow: none; -} -.tm-quark-textarea__input_empty:focus + .tm-quark-textarea__label { - color: #bbdefb; -} -.tm-quark-textarea__icon { - height: 20px; - position: absolute; - top: 20px; - width: 20px; -} -.tm-quark-textarea__icon::before { - background-position: center; - background-repeat: no-repeat; - content: ""; - height: 100%; - left: 50%; - position: absolute; - top: 50%; - -webkit-transform: translateX(-50%) translateY(-50%); - transform: translateX(-50%) translateY(-50%); - width: 100%; -} -.tm-quark-textarea__icon_type_field-type { - left: 20px; -} -.tm-quark-textarea__icon_type_validation-status { - -webkit-animation: TMQuarkInputShowValidationStatusIcon 0.25s cubic-bezier(0.645, 0.045, 0.355, 1); - animation: TMQuarkInputShowValidationStatusIcon 0.25s cubic-bezier(0.645, 0.045, 0.355, 1); - display: none; - right: 20px; -} -.tm-quark-textarea__input_valid ~ .tm-quark-textarea__icon_type_validation-status, -.tm-quark-textarea__input_invalid ~ .tm-quark-textarea__icon_type_validation-status { - display: block; -} -@-webkit-keyframes TMQuarkInputShowValidationStatusIcon { - from { - opacity: 0; - } - to { - opacity: 1; - } -} -@keyframes TMQuarkInputShowValidationStatusIcon { - from { - opacity: 0; - } - to { - opacity: 1; - } -} -.tm-quark-textarea__icon_check::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); -} -.tm-quark-textarea__icon_warning::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); -} -.tm-quark-textarea__icon_search::before, -.tm-quark-textarea__icon_maginifier::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); -} -.tm-quark-field__input:focus ~ .tm-quark-textarea__icon_search::before, -.tm-quark-field__input:focus ~ .tm-quark-textarea__icon_maginifier::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); -} -.tm-quark-textarea__icon_email::before, -.tm-quark-textarea__icon_letter::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); -} -.tm-quark-field__input:focus ~ .tm-quark-textarea__icon_email::before, -.tm-quark-field__input:focus ~ .tm-quark-textarea__icon_letter::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); -} -.tm-quark-textarea__icon_password::before, -.tm-quark-textarea__icon_key::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); -} -.tm-quark-field__input:focus ~ .tm-quark-textarea__icon_password::before, -.tm-quark-field__input:focus ~ .tm-quark-textarea__icon_key::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); -} -.tm-quark-textarea__icon_user::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); -} -.tm-quark-field__input:focus ~ .tm-quark-textarea__icon_user::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); -} -.tm-quark-textarea__symbols-counter { - bottom: 10px; - color: #90a4ae; - cursor: text; - font-size: 11px; - line-height: 16px; - position: absolute; - right: 20px; -} -/* colors */ -/* --- Hints --- */ -/* --- Typography Light --- */ -/* --- Typography Dark --- */ -/* --- Hints --- */ -/* --- Typography Light--- */ -/* --- Typography Dark--- */ -.TMUI__TypographyHeader { - display: inline-block; - margin: 0; - font-weight: 600; - color: #243238; -} -.TMUI__TypographyHeader--dark { - color: #FFFFFF; -} -.TMUI__TypographyHeader--dark a { - font-weight: 600; - color: #90CAF9; - text-decoration: none; -} -.TMUI__TypographyHeader--dark a:hover { - color: #BBDEFB; -} -.TMUI__TypographyHeader--0 { - font-size: 50px; - line-height: 105px; -} -.TMUI__TypographyHeader--1 { - font-size: 40px; - line-height: 52px; -} -.TMUI__TypographyHeader--2 { - font-size: 30px; - line-height: 39px; -} -.TMUI__TypographyHeader--3 { - font-size: 20px; - line-height: 30px; - text-transform: uppercase; - letter-spacing: 2px; -} -.TMUI__TypographyHeader a { - font-weight: 600; - color: #2196F3; - text-decoration: none; -} -.TMUI__TypographyHeader a:hover { - color: #0D47A1; -} -/* colors */ -/* --- Hints --- */ -/* --- Typography Light --- */ -/* --- Typography Dark --- */ -/* --- Hints --- */ -/* --- Typography Light--- */ -/* --- Typography Dark--- */ -.TMUI__TypographyText { - display: inline-block; - color: #243238; - margin: 0; -} -.TMUI__TypographyText a { - color: #2196F3; - text-decoration: none; -} -.TMUI__TypographyText a:hover { - color: #0D47A1; -} -.TMUI__TypographyText--1 { - font-size: 16px; - line-height: 24px; -} -.TMUI__TypographyText--2 { - font-size: 15px; - line-height: 22px; -} -.TMUI__TypographyText--3 { - font-size: 14px; - line-height: 21px; -} -.TMUI__TypographyText--4 { - font-size: 13px; - line-height: 20px; -} -.TMUI__TypographyText--5 { - font-size: 12px; - line-height: 18px; -} -.TMUI__TypographyText--6 { - font-size: 11px; - line-height: 16px; -} -.TMUI__TypographyText--success { - color: #1AB744; -} -.TMUI__TypographyText--success a { - color: #1AB744; -} -.TMUI__TypographyText--success a:hover { - color: #0B8738; -} -.TMUI__TypographyText--error { - color: #F4511E; -} -.TMUI__TypographyText--error a { - color: #F4511E; -} -.TMUI__TypographyText--error a:hover { - color: #BF360C; -} -.TMUI__TypographyText--secondary { - color: #90A4AE; -} -.TMUI__TypographyText--dark { - color: #FFFFFF; -} -.TMUI__TypographyText--dark a { - color: #90CAF9; - text-decoration: none; -} -.TMUI__TypographyText--dark a:hover { - color: #BBDEFB; -} -.TMUI__TypographyText--dark.TMUI__TypographyText--success { - color: #76D48F; -} -.TMUI__TypographyText--dark.TMUI__TypographyText--success a { - color: #76D48F; -} -.TMUI__TypographyText--dark.TMUI__TypographyText--success a:hover { - color: #A8E4BB; -} -.TMUI__TypographyText--dark.TMUI__TypographyText--error { - color: #FF8A65; -} -.TMUI__TypographyText--dark.TMUI__TypographyText--error a { - color: #FF8A65; -} -.TMUI__TypographyText--dark.TMUI__TypographyText--error a:hover { - color: #FFCCBC; -} -.TMUI__TypographyText--dark.TMUI__TypographyText--secondary { - color: #B0BEC5; -} -.stars-rating { - display: inline; -} -.stars-rating-wrapper { - position: relative; -} -.stars-rating__icon { - display: inline-block; - box-sizing: initial; - position: relative; - height: 20px; - width: 20px; - padding-right: 5px; - vertical-align: text-bottom; - background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 19' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E %3Cg id='Page-1' stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3E %3Cg id='Downloads-1024+' transform='translate(-619.000000, -889.000000)' fill='%23FFAB00'%3E %3Cg id='Download-item-2' transform='translate(380.000000, 758.000000)'%3E %3Cg id='Stars' transform='translate(239.000000, 131.000000)'%3E %3Cpolygon id='Star-1' points='10 15.7719334 3.81966011 19.0211303 5 12.1392207 6.03961325e-14 7.26542528 6.90983006 6.2613682 10 0 13.0901699 6.2613682 20 7.26542528 15 12.1392207 16.1803399 19.0211303'/%3E %3C/g%3E %3C/g%3E %3C/g%3E %3C/g%3E %3C/svg%3E"); - background-repeat: no-repeat; - border: 10px solid transparent; - border-right-width: 0; - border-left-width: 0; -} -.stars-rating__icon:last-child { - padding-right: 10px; -} -.stars-rating__icon:first-child { - border-left-width: 10px; -} -.stars-rating__icon_empty { - background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 19' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E %3Cg id='Page-1' stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3E %3Cg id='Downloads-1024+' transform='translate(-619.000000, -889.000000)' fill='none'%3E %3Cg id='Download-item-2' transform='translate(380.000000, 758.000000)'%3E %3Cg id='Stars' transform='translate(239.000000, 131.000000)'%3E %3Cpolygon stroke='%23B0BEC5' stroke-width='2' points='10 15.7719334 3.81966011 19.0211303 5 12.1392207 6.03961325e-14 7.26542528 6.90983006 6.2613682 10 0 13.0901699 6.2613682 20 7.26542528 15 12.1392207 16.1803399 19.0211303'/%3E %3C/g%3E %3C/g%3E %3C/g%3E %3C/g%3E %3C/svg%3E"); -} -.stars-rating__icon_half { - background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 19' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E %3Cdefs%3E %3Cpath id='a' d='M10 15.772l-6.18 3.25L5 12.138 0 7.265l6.91-1.004L10 0l3.09 6.261L20 7.265l-5 4.874 1.18 6.882z'/%3E %3Cmask id='b' x='0' y='0' width='20' height='19.021' fill='%23fff'%3E%3Cuse xlink:href='%23a'/%3E%3C/mask%3E %3C/defs%3E %3Cg fill='none' fill-rule='evenodd'%3E%3Cuse stroke='%23B0BEC5' fill='none' mask='url(%23b)' stroke-width='2' xlink:href='%23a'/%3E %3Cpath fill='%23FFAB00' d='M10 15.772l-6.18 3.25L5 12.138 0 7.265l6.91-1.004L10 0z'/%3E %3C/g%3E %3C/svg%3E"); -} -.stars-rating_hovered:hover .stars-rating__icon { - background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 19' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E %3Cg id='Page-1' stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3E %3Cg id='Downloads-1024+' transform='translate(-619.000000, -889.000000)' fill='%23FFAB00'%3E %3Cg id='Download-item-2' transform='translate(380.000000, 758.000000)'%3E %3Cg id='Stars' transform='translate(239.000000, 131.000000)'%3E %3Cpolygon id='Star-1' points='10 15.7719334 3.81966011 19.0211303 5 12.1392207 6.03961325e-14 7.26542528 6.90983006 6.2613682 10 0 13.0901699 6.2613682 20 7.26542528 15 12.1392207 16.1803399 19.0211303'/%3E %3C/g%3E %3C/g%3E %3C/g%3E %3C/g%3E %3C/svg%3E"); - cursor: pointer; -} -.stars-rating_hovered:hover .stars-rating__icon:hover { - background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 19' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E %3Cg id='Page-1' stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3E %3Cg id='Downloads-1024+' transform='translate(-619.000000, -889.000000)' fill='%23FFAB00'%3E %3Cg id='Download-item-2' transform='translate(380.000000, 758.000000)'%3E %3Cg id='Stars' transform='translate(239.000000, 131.000000)'%3E %3Cpolygon id='Star-1' points='10 15.7719334 3.81966011 19.0211303 5 12.1392207 6.03961325e-14 7.26542528 6.90983006 6.2613682 10 0 13.0901699 6.2613682 20 7.26542528 15 12.1392207 16.1803399 19.0211303'/%3E %3C/g%3E %3C/g%3E %3C/g%3E %3C/g%3E %3C/svg%3E"); -} -.stars-rating_hovered:hover .stars-rating__icon:hover ~ .stars-rating__icon { - background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 19' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E %3Cg id='Page-1' stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3E %3Cg id='Downloads-1024+' transform='translate(-619.000000, -889.000000)' fill='none'%3E %3Cg id='Download-item-2' transform='translate(380.000000, 758.000000)'%3E %3Cg id='Stars' transform='translate(239.000000, 131.000000)'%3E %3Cpolygon stroke='%23B0BEC5' stroke-width='2' points='10 15.7719334 3.81966011 19.0211303 5 12.1392207 6.03961325e-14 7.26542528 6.90983006 6.2613682 10 0 13.0901699 6.2613682 20 7.26542528 15 12.1392207 16.1803399 19.0211303'/%3E %3C/g%3E %3C/g%3E %3C/g%3E %3C/g%3E %3C/svg%3E"); -} -.stars-rating_no-hovered:hover .stars-rating__icon { - cursor: pointer; -} diff --git a/example/.gitignore b/example/.gitignore new file mode 100644 index 0000000..d30f40e --- /dev/null +++ b/example/.gitignore @@ -0,0 +1,21 @@ +# See https://help.github.com/ignore-files/ for more about ignoring files. + +# dependencies +/node_modules + +# testing +/coverage + +# production +/build + +# misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* diff --git a/example/README.md b/example/README.md new file mode 100644 index 0000000..c55ccdf --- /dev/null +++ b/example/README.md @@ -0,0 +1,2164 @@ +This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app). + +Below you will find some information on how to perform common tasks.
+You can find the most recent version of this guide [here](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md). + +## Table of Contents + +- [Updating to New Releases](#updating-to-new-releases) +- [Sending Feedback](#sending-feedback) +- [Folder Structure](#folder-structure) +- [Available Scripts](#available-scripts) + - [npm start](#npm-start) + - [npm test](#npm-test) + - [npm run build](#npm-run-build) + - [npm run eject](#npm-run-eject) +- [Supported Language Features and Polyfills](#supported-language-features-and-polyfills) +- [Syntax Highlighting in the Editor](#syntax-highlighting-in-the-editor) +- [Displaying Lint Output in the Editor](#displaying-lint-output-in-the-editor) +- [Debugging in the Editor](#debugging-in-the-editor) +- [Formatting Code Automatically](#formatting-code-automatically) +- [Changing the Page ``](#changing-the-page-title) +- [Installing a Dependency](#installing-a-dependency) +- [Importing a Component](#importing-a-component) +- [Code Splitting](#code-splitting) +- [Adding a Stylesheet](#adding-a-stylesheet) +- [Post-Processing CSS](#post-processing-css) +- [Adding a CSS Preprocessor (Sass, Less etc.)](#adding-a-css-preprocessor-sass-less-etc) +- [Adding Images, Fonts, and Files](#adding-images-fonts-and-files) +- [Using the `public` Folder](#using-the-public-folder) + - [Changing the HTML](#changing-the-html) + - [Adding Assets Outside of the Module System](#adding-assets-outside-of-the-module-system) + - [When to Use the `public` Folder](#when-to-use-the-public-folder) +- [Using Global Variables](#using-global-variables) +- [Adding Bootstrap](#adding-bootstrap) + - [Using a Custom Theme](#using-a-custom-theme) +- [Adding Flow](#adding-flow) +- [Adding Custom Environment Variables](#adding-custom-environment-variables) + - [Referencing Environment Variables in the HTML](#referencing-environment-variables-in-the-html) + - [Adding Temporary Environment Variables In Your Shell](#adding-temporary-environment-variables-in-your-shell) + - [Adding Development Environment Variables In `.env`](#adding-development-environment-variables-in-env) +- [Can I Use Decorators?](#can-i-use-decorators) +- [Integrating with an API Backend](#integrating-with-an-api-backend) + - [Node](#node) + - [Ruby on Rails](#ruby-on-rails) +- [Proxying API Requests in Development](#proxying-api-requests-in-development) + - ["Invalid Host Header" Errors After Configuring Proxy](#invalid-host-header-errors-after-configuring-proxy) + - [Configuring the Proxy Manually](#configuring-the-proxy-manually) + - [Configuring a WebSocket Proxy](#configuring-a-websocket-proxy) +- [Using HTTPS in Development](#using-https-in-development) +- [Generating Dynamic `<meta>` Tags on the Server](#generating-dynamic-meta-tags-on-the-server) +- [Pre-Rendering into Static HTML Files](#pre-rendering-into-static-html-files) +- [Injecting Data from the Server into the Page](#injecting-data-from-the-server-into-the-page) +- [Running Tests](#running-tests) + - [Filename Conventions](#filename-conventions) + - [Command Line Interface](#command-line-interface) + - [Version Control Integration](#version-control-integration) + - [Writing Tests](#writing-tests) + - [Testing Components](#testing-components) + - [Using Third Party Assertion Libraries](#using-third-party-assertion-libraries) + - [Initializing Test Environment](#initializing-test-environment) + - [Focusing and Excluding Tests](#focusing-and-excluding-tests) + - [Coverage Reporting](#coverage-reporting) + - [Continuous Integration](#continuous-integration) + - [Disabling jsdom](#disabling-jsdom) + - [Snapshot Testing](#snapshot-testing) + - [Editor Integration](#editor-integration) +- [Developing Components in Isolation](#developing-components-in-isolation) + - [Getting Started with Storybook](#getting-started-with-storybook) + - [Getting Started with Styleguidist](#getting-started-with-styleguidist) +- [Making a Progressive Web App](#making-a-progressive-web-app) + - [Opting Out of Caching](#opting-out-of-caching) + - [Offline-First Considerations](#offline-first-considerations) + - [Progressive Web App Metadata](#progressive-web-app-metadata) +- [Analyzing the Bundle Size](#analyzing-the-bundle-size) +- [Deployment](#deployment) + - [Static Server](#static-server) + - [Other Solutions](#other-solutions) + - [Serving Apps with Client-Side Routing](#serving-apps-with-client-side-routing) + - [Building for Relative Paths](#building-for-relative-paths) + - [Azure](#azure) + - [Firebase](#firebase) + - [GitHub Pages](#github-pages) + - [Heroku](#heroku) + - [Netlify](#netlify) + - [Now](#now) + - [S3 and CloudFront](#s3-and-cloudfront) + - [Surge](#surge) +- [Advanced Configuration](#advanced-configuration) +- [Troubleshooting](#troubleshooting) + - [`npm start` doesn’t detect changes](#npm-start-doesnt-detect-changes) + - [`npm test` hangs on macOS Sierra](#npm-test-hangs-on-macos-sierra) + - [`npm run build` exits too early](#npm-run-build-exits-too-early) + - [`npm run build` fails on Heroku](#npm-run-build-fails-on-heroku) + - [`npm run build` fails to minify](#npm-run-build-fails-to-minify) + - [Moment.js locales are missing](#momentjs-locales-are-missing) +- [Something Missing?](#something-missing) + +## Updating to New Releases + +Create React App is divided into two packages: + +* `create-react-app` is a global command-line utility that you use to create new projects. +* `react-scripts` is a development dependency in the generated projects (including this one). + +You almost never need to update `create-react-app` itself: it delegates all the setup to `react-scripts`. + +When you run `create-react-app`, it always creates the project with the latest version of `react-scripts` so you’ll get all the new features and improvements in newly created apps automatically. + +To update an existing project to a new version of `react-scripts`, [open the changelog](https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md), find the version you’re currently on (check `package.json` in this folder if you’re not sure), and apply the migration instructions for the newer versions. + +In most cases bumping the `react-scripts` version in `package.json` and running `npm install` in this folder should be enough, but it’s good to consult the [changelog](https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md) for potential breaking changes. + +We commit to keeping the breaking changes minimal so you can upgrade `react-scripts` painlessly. + +## Sending Feedback + +We are always open to [your feedback](https://github.com/facebookincubator/create-react-app/issues). + +## Folder Structure + +After creation, your project should look like this: + +``` +my-app/ + README.md + node_modules/ + package.json + public/ + index.html + favicon.ico + src/ + App.css + App.js + App.test.js + index.css + index.js + logo.svg +``` + +For the project to build, **these files must exist with exact filenames**: + +* `public/index.html` is the page template; +* `src/index.js` is the JavaScript entry point. + +You can delete or rename the other files. + +You may create subdirectories inside `src`. For faster rebuilds, only files inside `src` are processed by Webpack.<br> +You need to **put any JS and CSS files inside `src`**, otherwise Webpack won’t see them. + +Only files inside `public` can be used from `public/index.html`.<br> +Read instructions below for using assets from JavaScript and HTML. + +You can, however, create more top-level directories.<br> +They will not be included in the production build so you can use them for things like documentation. + +## Available Scripts + +In the project directory, you can run: + +### `npm start` + +Runs the app in the development mode.<br> +Open [http://localhost:3000](http://localhost:3000) to view it in the browser. + +The page will reload if you make edits.<br> +You will also see any lint errors in the console. + +### `npm test` + +Launches the test runner in the interactive watch mode.<br> +See the section about [running tests](#running-tests) for more information. + +### `npm run build` + +Builds the app for production to the `build` folder.<br> +It correctly bundles React in production mode and optimizes the build for the best performance. + +The build is minified and the filenames include the hashes.<br> +Your app is ready to be deployed! + +See the section about [deployment](#deployment) for more information. + +### `npm run eject` + +**Note: this is a one-way operation. Once you `eject`, you can’t go back!** + +If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. + +Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. + +You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. + +## Supported Language Features and Polyfills + +This project supports a superset of the latest JavaScript standard.<br> +In addition to [ES6](https://github.com/lukehoban/es6features) syntax features, it also supports: + +* [Exponentiation Operator](https://github.com/rwaldron/exponentiation-operator) (ES2016). +* [Async/await](https://github.com/tc39/ecmascript-asyncawait) (ES2017). +* [Object Rest/Spread Properties](https://github.com/sebmarkbage/ecmascript-rest-spread) (stage 3 proposal). +* [Dynamic import()](https://github.com/tc39/proposal-dynamic-import) (stage 3 proposal) +* [Class Fields and Static Properties](https://github.com/tc39/proposal-class-public-fields) (stage 2 proposal). +* [JSX](https://facebook.github.io/react/docs/introducing-jsx.html) and [Flow](https://flowtype.org/) syntax. + +Learn more about [different proposal stages](https://babeljs.io/docs/plugins/#presets-stage-x-experimental-presets-). + +While we recommend to use experimental proposals with some caution, Facebook heavily uses these features in the product code, so we intend to provide [codemods](https://medium.com/@cpojer/effective-javascript-codemods-5a6686bb46fb) if any of these proposals change in the future. + +Note that **the project only includes a few ES6 [polyfills](https://en.wikipedia.org/wiki/Polyfill)**: + +* [`Object.assign()`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) via [`object-assign`](https://github.com/sindresorhus/object-assign). +* [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) via [`promise`](https://github.com/then/promise). +* [`fetch()`](https://developer.mozilla.org/en/docs/Web/API/Fetch_API) via [`whatwg-fetch`](https://github.com/github/fetch). + +If you use any other ES6+ features that need **runtime support** (such as `Array.from()` or `Symbol`), make sure you are including the appropriate polyfills manually, or that the browsers you are targeting already support them. + +## Syntax Highlighting in the Editor + +To configure the syntax highlighting in your favorite text editor, head to the [relevant Babel documentation page](https://babeljs.io/docs/editors) and follow the instructions. Some of the most popular editors are covered. + +## Displaying Lint Output in the Editor + +>Note: this feature is available with `react-scripts@0.2.0` and higher.<br> +>It also only works with npm 3 or higher. + +Some editors, including Sublime Text, Atom, and Visual Studio Code, provide plugins for ESLint. + +They are not required for linting. You should see the linter output right in your terminal as well as the browser console. However, if you prefer the lint results to appear right in your editor, there are some extra steps you can do. + +You would need to install an ESLint plugin for your editor first. Then, add a file called `.eslintrc` to the project root: + +```js +{ + "extends": "react-app" +} +``` + +Now your editor should report the linting warnings. + +Note that even if you edit your `.eslintrc` file further, these changes will **only affect the editor integration**. They won’t affect the terminal and in-browser lint output. This is because Create React App intentionally provides a minimal set of rules that find common mistakes. + +If you want to enforce a coding style for your project, consider using [Prettier](https://github.com/jlongster/prettier) instead of ESLint style rules. + +## Debugging in the Editor + +**This feature is currently only supported by [Visual Studio Code](https://code.visualstudio.com) and [WebStorm](https://www.jetbrains.com/webstorm/).** + +Visual Studio Code and WebStorm support debugging out of the box with Create React App. This enables you as a developer to write and debug your React code without leaving the editor, and most importantly it enables you to have a continuous development workflow, where context switching is minimal, as you don’t have to switch between tools. + +### Visual Studio Code + +You would need to have the latest version of [VS Code](https://code.visualstudio.com) and VS Code [Chrome Debugger Extension](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome) installed. + +Then add the block below to your `launch.json` file and put it inside the `.vscode` folder in your app’s root directory. + +```json +{ + "version": "0.2.0", + "configurations": [{ + "name": "Chrome", + "type": "chrome", + "request": "launch", + "url": "http://localhost:3000", + "webRoot": "${workspaceRoot}/src", + "userDataDir": "${workspaceRoot}/.vscode/chrome", + "sourceMapPathOverrides": { + "webpack:///src/*": "${webRoot}/*" + } + }] +} +``` +>Note: the URL may be different if you've made adjustments via the [HOST or PORT environment variables](#advanced-configuration). + +Start your app by running `npm start`, and start debugging in VS Code by pressing `F5` or by clicking the green debug icon. You can now write code, set breakpoints, make changes to the code, and debug your newly modified code—all from your editor. + +### WebStorm + +You would need to have [WebStorm](https://www.jetbrains.com/webstorm/) and [JetBrains IDE Support](https://chrome.google.com/webstore/detail/jetbrains-ide-support/hmhgeddbohgjknpmjagkdomcpobmllji) Chrome extension installed. + +In the WebStorm menu `Run` select `Edit Configurations...`. Then click `+` and select `JavaScript Debug`. Paste `http://localhost:3000` into the URL field and save the configuration. + +>Note: the URL may be different if you've made adjustments via the [HOST or PORT environment variables](#advanced-configuration). + +Start your app by running `npm start`, then press `^D` on macOS or `F9` on Windows and Linux or click the green debug icon to start debugging in WebStorm. + +The same way you can debug your application in IntelliJ IDEA Ultimate, PhpStorm, PyCharm Pro, and RubyMine. + +## Formatting Code Automatically + +Prettier is an opinionated code formatter with support for JavaScript, CSS and JSON. With Prettier you can format the code you write automatically to ensure a code style within your project. See the [Prettier's GitHub page](https://github.com/prettier/prettier) for more information, and look at this [page to see it in action](https://prettier.github.io/prettier/). + +To format our code whenever we make a commit in git, we need to install the following dependencies: + +```sh +npm install --save husky lint-staged prettier +``` + +Alternatively you may use `yarn`: + +```sh +yarn add husky lint-staged prettier +``` + +* `husky` makes it easy to use githooks as if they are npm scripts. +* `lint-staged` allows us to run scripts on staged files in git. See this [blog post about lint-staged to learn more about it](https://medium.com/@okonetchnikov/make-linting-great-again-f3890e1ad6b8). +* `prettier` is the JavaScript formatter we will run before commits. + +Now we can make sure every file is formatted correctly by adding a few lines to the `package.json` in the project root. + +Add the following line to `scripts` section: + +```diff + "scripts": { ++ "precommit": "lint-staged", + "start": "react-scripts start", + "build": "react-scripts build", +``` + +Next we add a 'lint-staged' field to the `package.json`, for example: + +```diff + "dependencies": { + // ... + }, ++ "lint-staged": { ++ "src/**/*.{js,jsx,json,css}": [ ++ "prettier --single-quote --write", ++ "git add" ++ ] ++ }, + "scripts": { +``` + +Now, whenever you make a commit, Prettier will format the changed files automatically. You can also run `./node_modules/.bin/prettier --single-quote --write "src/**/*.{js,jsx}"` to format your entire project for the first time. + +Next you might want to integrate Prettier in your favorite editor. Read the section on [Editor Integration](https://github.com/prettier/prettier#editor-integration) on the Prettier GitHub page. + +## Changing the Page `<title>` + +You can find the source HTML file in the `public` folder of the generated project. You may edit the `<title>` tag in it to change the title from “React App” to anything else. + +Note that normally you wouldn’t edit files in the `public` folder very often. For example, [adding a stylesheet](#adding-a-stylesheet) is done without touching the HTML. + +If you need to dynamically update the page title based on the content, you can use the browser [`document.title`](https://developer.mozilla.org/en-US/docs/Web/API/Document/title) API. For more complex scenarios when you want to change the title from React components, you can use [React Helmet](https://github.com/nfl/react-helmet), a third party library. + +If you use a custom server for your app in production and want to modify the title before it gets sent to the browser, you can follow advice in [this section](#generating-dynamic-meta-tags-on-the-server). Alternatively, you can pre-build each page as a static HTML file which then loads the JavaScript bundle, which is covered [here](#pre-rendering-into-static-html-files). + +## Installing a Dependency + +The generated project includes React and ReactDOM as dependencies. It also includes a set of scripts used by Create React App as a development dependency. You may install other dependencies (for example, React Router) with `npm`: + +```sh +npm install --save react-router +``` + +Alternatively you may use `yarn`: + +```sh +yarn add react-router +``` + +This works for any library, not just `react-router`. + +## Importing a Component + +This project setup supports ES6 modules thanks to Babel.<br> +While you can still use `require()` and `module.exports`, we encourage you to use [`import` and `export`](http://exploringjs.com/es6/ch_modules.html) instead. + +For example: + +### `Button.js` + +```js +import React, { Component } from 'react'; + +class Button extends Component { + render() { + // ... + } +} + +export default Button; // Don’t forget to use export default! +``` + +### `DangerButton.js` + + +```js +import React, { Component } from 'react'; +import Button from './Button'; // Import a component from another file + +class DangerButton extends Component { + render() { + return <Button color="red" />; + } +} + +export default DangerButton; +``` + +Be aware of the [difference between default and named exports](http://stackoverflow.com/questions/36795819/react-native-es-6-when-should-i-use-curly-braces-for-import/36796281#36796281). It is a common source of mistakes. + +We suggest that you stick to using default imports and exports when a module only exports a single thing (for example, a component). That’s what you get when you use `export default Button` and `import Button from './Button'`. + +Named exports are useful for utility modules that export several functions. A module may have at most one default export and as many named exports as you like. + +Learn more about ES6 modules: + +* [When to use the curly braces?](http://stackoverflow.com/questions/36795819/react-native-es-6-when-should-i-use-curly-braces-for-import/36796281#36796281) +* [Exploring ES6: Modules](http://exploringjs.com/es6/ch_modules.html) +* [Understanding ES6: Modules](https://leanpub.com/understandinges6/read#leanpub-auto-encapsulating-code-with-modules) + +## Code Splitting + +Instead of downloading the entire app before users can use it, code splitting allows you to split your code into small chunks which you can then load on demand. + +This project setup supports code splitting via [dynamic `import()`](http://2ality.com/2017/01/import-operator.html#loading-code-on-demand). Its [proposal](https://github.com/tc39/proposal-dynamic-import) is in stage 3. The `import()` function-like form takes the module name as an argument and returns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) which always resolves to the namespace object of the module. + +Here is an example: + +### `moduleA.js` + +```js +const moduleA = 'Hello'; + +export { moduleA }; +``` +### `App.js` + +```js +import React, { Component } from 'react'; + +class App extends Component { + handleClick = () => { + import('./moduleA') + .then(({ moduleA }) => { + // Use moduleA + }) + .catch(err => { + // Handle failure + }); + }; + + render() { + return ( + <div> + <button onClick={this.handleClick}>Load</button> + </div> + ); + } +} + +export default App; +``` + +This will make `moduleA.js` and all its unique dependencies as a separate chunk that only loads after the user clicks the 'Load' button. + +You can also use it with `async` / `await` syntax if you prefer it. + +### With React Router + +If you are using React Router check out [this tutorial](http://serverless-stack.com/chapters/code-splitting-in-create-react-app.html) on how to use code splitting with it. You can find the companion GitHub repository [here](https://github.com/AnomalyInnovations/serverless-stack-demo-client/tree/code-splitting-in-create-react-app). + +## Adding a Stylesheet + +This project setup uses [Webpack](https://webpack.js.org/) for handling all assets. Webpack offers a custom way of “extending” the concept of `import` beyond JavaScript. To express that a JavaScript file depends on a CSS file, you need to **import the CSS from the JavaScript file**: + +### `Button.css` + +```css +.Button { + padding: 20px; +} +``` + +### `Button.js` + +```js +import React, { Component } from 'react'; +import './Button.css'; // Tell Webpack that Button.js uses these styles + +class Button extends Component { + render() { + // You can use them as regular CSS styles + return <div className="Button" />; + } +} +``` + +**This is not required for React** but many people find this feature convenient. You can read about the benefits of this approach [here](https://medium.com/seek-ui-engineering/block-element-modifying-your-javascript-components-d7f99fcab52b). However you should be aware that this makes your code less portable to other build tools and environments than Webpack. + +In development, expressing dependencies this way allows your styles to be reloaded on the fly as you edit them. In production, all CSS files will be concatenated into a single minified `.css` file in the build output. + +If you are concerned about using Webpack-specific semantics, you can put all your CSS right into `src/index.css`. It would still be imported from `src/index.js`, but you could always remove that import if you later migrate to a different build tool. + +## Post-Processing CSS + +This project setup minifies your CSS and adds vendor prefixes to it automatically through [Autoprefixer](https://github.com/postcss/autoprefixer) so you don’t need to worry about it. + +For example, this: + +```css +.App { + display: flex; + flex-direction: row; + align-items: center; +} +``` + +becomes this: + +```css +.App { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: horizontal; + -webkit-box-direction: normal; + -ms-flex-direction: row; + flex-direction: row; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} +``` + +If you need to disable autoprefixing for some reason, [follow this section](https://github.com/postcss/autoprefixer#disabling). + +## Adding a CSS Preprocessor (Sass, Less etc.) + +Generally, we recommend that you don’t reuse the same CSS classes across different components. For example, instead of using a `.Button` CSS class in `<AcceptButton>` and `<RejectButton>` components, we recommend creating a `<Button>` component with its own `.Button` styles, that both `<AcceptButton>` and `<RejectButton>` can render (but [not inherit](https://facebook.github.io/react/docs/composition-vs-inheritance.html)). + +Following this rule often makes CSS preprocessors less useful, as features like mixins and nesting are replaced by component composition. You can, however, integrate a CSS preprocessor if you find it valuable. In this walkthrough, we will be using Sass, but you can also use Less, or another alternative. + +First, let’s install the command-line interface for Sass: + +```sh +npm install --save node-sass-chokidar +``` + +Alternatively you may use `yarn`: + +```sh +yarn add node-sass-chokidar +``` + +Then in `package.json`, add the following lines to `scripts`: + +```diff + "scripts": { ++ "build-css": "node-sass-chokidar src/ -o src/", ++ "watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive", + "start": "react-scripts start", + "build": "react-scripts build", + "test": "react-scripts test --env=jsdom", +``` + +>Note: To use a different preprocessor, replace `build-css` and `watch-css` commands according to your preprocessor’s documentation. + +Now you can rename `src/App.css` to `src/App.scss` and run `npm run watch-css`. The watcher will find every Sass file in `src` subdirectories, and create a corresponding CSS file next to it, in our case overwriting `src/App.css`. Since `src/App.js` still imports `src/App.css`, the styles become a part of your application. You can now edit `src/App.scss`, and `src/App.css` will be regenerated. + +To share variables between Sass files, you can use Sass imports. For example, `src/App.scss` and other component style files could include `@import "./shared.scss";` with variable definitions. + +To enable importing files without using relative paths, you can add the `--include-path` option to the command in `package.json`. + +``` +"build-css": "node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/", +"watch-css": "npm run build-css && node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/ --watch --recursive", +``` + +This will allow you to do imports like + +```scss +@import 'styles/_colors.scss'; // assuming a styles directory under src/ +@import 'nprogress/nprogress'; // importing a css file from the nprogress node module +``` + +At this point you might want to remove all CSS files from the source control, and add `src/**/*.css` to your `.gitignore` file. It is generally a good practice to keep the build products outside of the source control. + +As a final step, you may find it convenient to run `watch-css` automatically with `npm start`, and run `build-css` as a part of `npm run build`. You can use the `&&` operator to execute two scripts sequentially. However, there is no cross-platform way to run two scripts in parallel, so we will install a package for this: + +```sh +npm install --save npm-run-all +``` + +Alternatively you may use `yarn`: + +```sh +yarn add npm-run-all +``` + +Then we can change `start` and `build` scripts to include the CSS preprocessor commands: + +```diff + "scripts": { + "build-css": "node-sass-chokidar src/ -o src/", + "watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive", +- "start": "react-scripts start", +- "build": "react-scripts build", ++ "start-js": "react-scripts start", ++ "start": "npm-run-all -p watch-css start-js", ++ "build": "npm run build-css && react-scripts build", + "test": "react-scripts test --env=jsdom", + "eject": "react-scripts eject" + } +``` + +Now running `npm start` and `npm run build` also builds Sass files. + +**Why `node-sass-chokidar`?** + +`node-sass` has been reported as having the following issues: + +- `node-sass --watch` has been reported to have *performance issues* in certain conditions when used in a virtual machine or with docker. + +- Infinite styles compiling [#1939](https://github.com/facebookincubator/create-react-app/issues/1939) + +- `node-sass` has been reported as having issues with detecting new files in a directory [#1891](https://github.com/sass/node-sass/issues/1891) + + `node-sass-chokidar` is used here as it addresses these issues. + +## Adding Images, Fonts, and Files + +With Webpack, using static assets like images and fonts works similarly to CSS. + +You can **`import` a file right in a JavaScript module**. This tells Webpack to include that file in the bundle. Unlike CSS imports, importing a file gives you a string value. This value is the final path you can reference in your code, e.g. as the `src` attribute of an image or the `href` of a link to a PDF. + +To reduce the number of requests to the server, importing images that are less than 10,000 bytes returns a [data URI](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) instead of a path. This applies to the following file extensions: bmp, gif, jpg, jpeg, and png. SVG files are excluded due to [#1153](https://github.com/facebookincubator/create-react-app/issues/1153). + +Here is an example: + +```js +import React from 'react'; +import logo from './logo.png'; // Tell Webpack this JS file uses this image + +console.log(logo); // /logo.84287d09.png + +function Header() { + // Import result is the URL of your image + return <img src={logo} alt="Logo" />; +} + +export default Header; +``` + +This ensures that when the project is built, Webpack will correctly move the images into the build folder, and provide us with correct paths. + +This works in CSS too: + +```css +.Logo { + background-image: url(./logo.png); +} +``` + +Webpack finds all relative module references in CSS (they start with `./`) and replaces them with the final paths from the compiled bundle. If you make a typo or accidentally delete an important file, you will see a compilation error, just like when you import a non-existent JavaScript module. The final filenames in the compiled bundle are generated by Webpack from content hashes. If the file content changes in the future, Webpack will give it a different name in production so you don’t need to worry about long-term caching of assets. + +Please be advised that this is also a custom feature of Webpack. + +**It is not required for React** but many people enjoy it (and React Native uses a similar mechanism for images).<br> +An alternative way of handling static assets is described in the next section. + +## Using the `public` Folder + +>Note: this feature is available with `react-scripts@0.5.0` and higher. + +### Changing the HTML + +The `public` folder contains the HTML file so you can tweak it, for example, to [set the page title](#changing-the-page-title). +The `<script>` tag with the compiled code will be added to it automatically during the build process. + +### Adding Assets Outside of the Module System + +You can also add other assets to the `public` folder. + +Note that we normally encourage you to `import` assets in JavaScript files instead. +For example, see the sections on [adding a stylesheet](#adding-a-stylesheet) and [adding images and fonts](#adding-images-fonts-and-files). +This mechanism provides a number of benefits: + +* Scripts and stylesheets get minified and bundled together to avoid extra network requests. +* Missing files cause compilation errors instead of 404 errors for your users. +* Result filenames include content hashes so you don’t need to worry about browsers caching their old versions. + +However there is an **escape hatch** that you can use to add an asset outside of the module system. + +If you put a file into the `public` folder, it will **not** be processed by Webpack. Instead it will be copied into the build folder untouched. To reference assets in the `public` folder, you need to use a special variable called `PUBLIC_URL`. + +Inside `index.html`, you can use it like this: + +```html +<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico"> +``` + +Only files inside the `public` folder will be accessible by `%PUBLIC_URL%` prefix. If you need to use a file from `src` or `node_modules`, you’ll have to copy it there to explicitly specify your intention to make this file a part of the build. + +When you run `npm run build`, Create React App will substitute `%PUBLIC_URL%` with a correct absolute path so your project works even if you use client-side routing or host it at a non-root URL. + +In JavaScript code, you can use `process.env.PUBLIC_URL` for similar purposes: + +```js +render() { + // Note: this is an escape hatch and should be used sparingly! + // Normally we recommend using `import` for getting asset URLs + // as described in “Adding Images and Fonts” above this section. + return <img src={process.env.PUBLIC_URL + '/img/logo.png'} />; +} +``` + +Keep in mind the downsides of this approach: + +* None of the files in `public` folder get post-processed or minified. +* Missing files will not be called at compilation time, and will cause 404 errors for your users. +* Result filenames won’t include content hashes so you’ll need to add query arguments or rename them every time they change. + +### When to Use the `public` Folder + +Normally we recommend importing [stylesheets](#adding-a-stylesheet), [images, and fonts](#adding-images-fonts-and-files) from JavaScript. +The `public` folder is useful as a workaround for a number of less common cases: + +* You need a file with a specific name in the build output, such as [`manifest.webmanifest`](https://developer.mozilla.org/en-US/docs/Web/Manifest). +* You have thousands of images and need to dynamically reference their paths. +* You want to include a small script like [`pace.js`](http://github.hubspot.com/pace/docs/welcome/) outside of the bundled code. +* Some library may be incompatible with Webpack and you have no other option but to include it as a `<script>` tag. + +Note that if you add a `<script>` that declares global variables, you also need to read the next section on using them. + +## Using Global Variables + +When you include a script in the HTML file that defines global variables and try to use one of these variables in the code, the linter will complain because it cannot see the definition of the variable. + +You can avoid this by reading the global variable explicitly from the `window` object, for example: + +```js +const $ = window.$; +``` + +This makes it obvious you are using a global variable intentionally rather than because of a typo. + +Alternatively, you can force the linter to ignore any line by adding `// eslint-disable-line` after it. + +## Adding Bootstrap + +You don’t have to use [React Bootstrap](https://react-bootstrap.github.io) together with React but it is a popular library for integrating Bootstrap with React apps. If you need it, you can integrate it with Create React App by following these steps: + +Install React Bootstrap and Bootstrap from npm. React Bootstrap does not include Bootstrap CSS so this needs to be installed as well: + +```sh +npm install --save react-bootstrap bootstrap@3 +``` + +Alternatively you may use `yarn`: + +```sh +yarn add react-bootstrap bootstrap@3 +``` + +Import Bootstrap CSS and optionally Bootstrap theme CSS in the beginning of your ```src/index.js``` file: + +```js +import 'bootstrap/dist/css/bootstrap.css'; +import 'bootstrap/dist/css/bootstrap-theme.css'; +// Put any other imports below so that CSS from your +// components takes precedence over default styles. +``` + +Import required React Bootstrap components within ```src/App.js``` file or your custom component files: + +```js +import { Navbar, Jumbotron, Button } from 'react-bootstrap'; +``` + +Now you are ready to use the imported React Bootstrap components within your component hierarchy defined in the render method. Here is an example [`App.js`](https://gist.githubusercontent.com/gaearon/85d8c067f6af1e56277c82d19fd4da7b/raw/6158dd991b67284e9fc8d70b9d973efe87659d72/App.js) redone using React Bootstrap. + +### Using a Custom Theme + +Sometimes you might need to tweak the visual styles of Bootstrap (or equivalent package).<br> +We suggest the following approach: + +* Create a new package that depends on the package you wish to customize, e.g. Bootstrap. +* Add the necessary build steps to tweak the theme, and publish your package on npm. +* Install your own theme npm package as a dependency of your app. + +Here is an example of adding a [customized Bootstrap](https://medium.com/@tacomanator/customizing-create-react-app-aa9ffb88165) that follows these steps. + +## Adding Flow + +Flow is a static type checker that helps you write code with fewer bugs. Check out this [introduction to using static types in JavaScript](https://medium.com/@preethikasireddy/why-use-static-types-in-javascript-part-1-8382da1e0adb) if you are new to this concept. + +Recent versions of [Flow](http://flowtype.org/) work with Create React App projects out of the box. + +To add Flow to a Create React App project, follow these steps: + +1. Run `npm install --save flow-bin` (or `yarn add flow-bin`). +2. Add `"flow": "flow"` to the `scripts` section of your `package.json`. +3. Run `npm run flow init` (or `yarn flow init`) to create a [`.flowconfig` file](https://flowtype.org/docs/advanced-configuration.html) in the root directory. +4. Add `// @flow` to any files you want to type check (for example, to `src/App.js`). + +Now you can run `npm run flow` (or `yarn flow`) to check the files for type errors. +You can optionally use an IDE like [Nuclide](https://nuclide.io/docs/languages/flow/) for a better integrated experience. +In the future we plan to integrate it into Create React App even more closely. + +To learn more about Flow, check out [its documentation](https://flowtype.org/). + +## Adding Custom Environment Variables + +>Note: this feature is available with `react-scripts@0.2.3` and higher. + +Your project can consume variables declared in your environment as if they were declared locally in your JS files. By +default you will have `NODE_ENV` defined for you, and any other environment variables starting with +`REACT_APP_`. + +**The environment variables are embedded during the build time**. Since Create React App produces a static HTML/CSS/JS bundle, it can’t possibly read them at runtime. To read them at runtime, you would need to load HTML into memory on the server and replace placeholders in runtime, just like [described here](#injecting-data-from-the-server-into-the-page). Alternatively you can rebuild the app on the server anytime you change them. + +>Note: You must create custom environment variables beginning with `REACT_APP_`. Any other variables except `NODE_ENV` will be ignored to avoid accidentally [exposing a private key on the machine that could have the same name](https://github.com/facebookincubator/create-react-app/issues/865#issuecomment-252199527). Changing any environment variables will require you to restart the development server if it is running. + +These environment variables will be defined for you on `process.env`. For example, having an environment +variable named `REACT_APP_SECRET_CODE` will be exposed in your JS as `process.env.REACT_APP_SECRET_CODE`. + +There is also a special built-in environment variable called `NODE_ENV`. You can read it from `process.env.NODE_ENV`. When you run `npm start`, it is always equal to `'development'`, when you run `npm test` it is always equal to `'test'`, and when you run `npm run build` to make a production bundle, it is always equal to `'production'`. **You cannot override `NODE_ENV` manually.** This prevents developers from accidentally deploying a slow development build to production. + +These environment variables can be useful for displaying information conditionally based on where the project is +deployed or consuming sensitive data that lives outside of version control. + +First, you need to have environment variables defined. For example, let’s say you wanted to consume a secret defined +in the environment inside a `<form>`: + +```jsx +render() { + return ( + <div> + <small>You are running this application in <b>{process.env.NODE_ENV}</b> mode.</small> + <form> + <input type="hidden" defaultValue={process.env.REACT_APP_SECRET_CODE} /> + </form> + </div> + ); +} +``` + +During the build, `process.env.REACT_APP_SECRET_CODE` will be replaced with the current value of the `REACT_APP_SECRET_CODE` environment variable. Remember that the `NODE_ENV` variable will be set for you automatically. + +When you load the app in the browser and inspect the `<input>`, you will see its value set to `abcdef`, and the bold text will show the environment provided when using `npm start`: + +```html +<div> + <small>You are running this application in <b>development</b> mode.</small> + <form> + <input type="hidden" value="abcdef" /> + </form> +</div> +``` + +The above form is looking for a variable called `REACT_APP_SECRET_CODE` from the environment. In order to consume this +value, we need to have it defined in the environment. This can be done using two ways: either in your shell or in +a `.env` file. Both of these ways are described in the next few sections. + +Having access to the `NODE_ENV` is also useful for performing actions conditionally: + +```js +if (process.env.NODE_ENV !== 'production') { + analytics.disable(); +} +``` + +When you compile the app with `npm run build`, the minification step will strip out this condition, and the resulting bundle will be smaller. + +### Referencing Environment Variables in the HTML + +>Note: this feature is available with `react-scripts@0.9.0` and higher. + +You can also access the environment variables starting with `REACT_APP_` in the `public/index.html`. For example: + +```html +<title>%REACT_APP_WEBSITE_NAME% +``` + +Note that the caveats from the above section apply: + +* Apart from a few built-in variables (`NODE_ENV` and `PUBLIC_URL`), variable names must start with `REACT_APP_` to work. +* The environment variables are injected at build time. If you need to inject them at runtime, [follow this approach instead](#generating-dynamic-meta-tags-on-the-server). + +### Adding Temporary Environment Variables In Your Shell + +Defining environment variables can vary between OSes. It’s also important to know that this manner is temporary for the +life of the shell session. + +#### Windows (cmd.exe) + +```cmd +set REACT_APP_SECRET_CODE=abcdef&&npm start +``` + +(Note: the lack of whitespace is intentional.) + +#### Linux, macOS (Bash) + +```bash +REACT_APP_SECRET_CODE=abcdef npm start +``` + +### Adding Development Environment Variables In `.env` + +>Note: this feature is available with `react-scripts@0.5.0` and higher. + +To define permanent environment variables, create a file called `.env` in the root of your project: + +``` +REACT_APP_SECRET_CODE=abcdef +``` + +`.env` files **should be** checked into source control (with the exclusion of `.env*.local`). + +#### What other `.env` files are can be used? + +>Note: this feature is **available with `react-scripts@1.0.0` and higher**. + +* `.env`: Default. +* `.env.local`: Local overrides. **This file is loaded for all environments except test.** +* `.env.development`, `.env.test`, `.env.production`: Environment-specific settings. +* `.env.development.local`, `.env.test.local`, `.env.production.local`: Local overrides of environment-specific settings. + +Files on the left have more priority than files on the right: + +* `npm start`: `.env.development.local`, `.env.development`, `.env.local`, `.env` +* `npm run build`: `.env.production.local`, `.env.production`, `.env.local`, `.env` +* `npm test`: `.env.test.local`, `.env.test`, `.env` (note `.env.local` is missing) + +These variables will act as the defaults if the machine does not explicitly set them.
+Please refer to the [dotenv documentation](https://github.com/motdotla/dotenv) for more details. + +>Note: If you are defining environment variables for development, your CI and/or hosting platform will most likely need +these defined as well. Consult their documentation how to do this. For example, see the documentation for [Travis CI](https://docs.travis-ci.com/user/environment-variables/) or [Heroku](https://devcenter.heroku.com/articles/config-vars). + +## Can I Use Decorators? + +Many popular libraries use [decorators](https://medium.com/google-developers/exploring-es7-decorators-76ecb65fb841) in their documentation.
+Create React App doesn’t support decorator syntax at the moment because: + +* It is an experimental proposal and is subject to change. +* The current specification version is not officially supported by Babel. +* If the specification changes, we won’t be able to write a codemod because we don’t use them internally at Facebook. + +However in many cases you can rewrite decorator-based code without decorators just as fine.
+Please refer to these two threads for reference: + +* [#214](https://github.com/facebookincubator/create-react-app/issues/214) +* [#411](https://github.com/facebookincubator/create-react-app/issues/411) + +Create React App will add decorator support when the specification advances to a stable stage. + +## Integrating with an API Backend + +These tutorials will help you to integrate your app with an API backend running on another port, +using `fetch()` to access it. + +### Node +Check out [this tutorial](https://www.fullstackreact.com/articles/using-create-react-app-with-a-server/). +You can find the companion GitHub repository [here](https://github.com/fullstackreact/food-lookup-demo). + +### Ruby on Rails + +Check out [this tutorial](https://www.fullstackreact.com/articles/how-to-get-create-react-app-to-work-with-your-rails-api/). +You can find the companion GitHub repository [here](https://github.com/fullstackreact/food-lookup-demo-rails). + +## Proxying API Requests in Development + +>Note: this feature is available with `react-scripts@0.2.3` and higher. + +People often serve the front-end React app from the same host and port as their backend implementation.
+For example, a production setup might look like this after the app is deployed: + +``` +/ - static server returns index.html with React app +/todos - static server returns index.html with React app +/api/todos - server handles any /api/* requests using the backend implementation +``` + +Such setup is **not** required. However, if you **do** have a setup like this, it is convenient to write requests like `fetch('/api/todos')` without worrying about redirecting them to another host or port during development. + +To tell the development server to proxy any unknown requests to your API server in development, add a `proxy` field to your `package.json`, for example: + +```js + "proxy": "http://localhost:4000", +``` + +This way, when you `fetch('/api/todos')` in development, the development server will recognize that it’s not a static asset, and will proxy your request to `http://localhost:4000/api/todos` as a fallback. The development server will only attempt to send requests without a `text/html` accept header to the proxy. + +Conveniently, this avoids [CORS issues](http://stackoverflow.com/questions/21854516/understanding-ajax-cors-and-security-considerations) and error messages like this in development: + +``` +Fetch API cannot load http://localhost:4000/api/todos. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. +``` + +Keep in mind that `proxy` only has effect in development (with `npm start`), and it is up to you to ensure that URLs like `/api/todos` point to the right thing in production. You don’t have to use the `/api` prefix. Any unrecognized request without a `text/html` accept header will be redirected to the specified `proxy`. + +The `proxy` option supports HTTP, HTTPS and WebSocket connections.
+If the `proxy` option is **not** flexible enough for you, alternatively you can: + +* [Configure the proxy yourself](#configuring-the-proxy-manually) +* Enable CORS on your server ([here’s how to do it for Express](http://enable-cors.org/server_expressjs.html)). +* Use [environment variables](#adding-custom-environment-variables) to inject the right server host and port into your app. + +### "Invalid Host Header" Errors After Configuring Proxy + +When you enable the `proxy` option, you opt into a more strict set of host checks. This is necessary because leaving the backend open to remote hosts makes your computer vulnerable to DNS rebinding attacks. The issue is explained in [this article](https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a) and [this issue](https://github.com/webpack/webpack-dev-server/issues/887). + +This shouldn’t affect you when developing on `localhost`, but if you develop remotely like [described here](https://github.com/facebookincubator/create-react-app/issues/2271), you will see this error in the browser after enabling the `proxy` option: + +>Invalid Host header + +To work around it, you can specify your public development host in a file called `.env.development` in the root of your project: + +``` +HOST=mypublicdevhost.com +``` + +If you restart the development server now and load the app from the specified host, it should work. + +If you are still having issues or if you’re using a more exotic environment like a cloud editor, you can bypass the host check completely by adding a line to `.env.development.local`. **Note that this is dangerous and exposes your machine to remote code execution from malicious websites:** + +``` +# NOTE: THIS IS DANGEROUS! +# It exposes your machine to attacks from the websites you visit. +DANGEROUSLY_DISABLE_HOST_CHECK=true +``` + +We don’t recommend this approach. + +### Configuring the Proxy Manually + +>Note: this feature is available with `react-scripts@1.0.0` and higher. + +If the `proxy` option is **not** flexible enough for you, you can specify an object in the following form (in `package.json`).
+You may also specify any configuration value [`http-proxy-middleware`](https://github.com/chimurai/http-proxy-middleware#options) or [`http-proxy`](https://github.com/nodejitsu/node-http-proxy#options) supports. +```js +{ + // ... + "proxy": { + "/api": { + "target": "", + "ws": true + // ... + } + } + // ... +} +``` + +All requests matching this path will be proxies, no exceptions. This includes requests for `text/html`, which the standard `proxy` option does not proxy. + +If you need to specify multiple proxies, you may do so by specifying additional entries. +You may also narrow down matches using `*` and/or `**`, to match the path exactly or any subpath. +```js +{ + // ... + "proxy": { + // Matches any request starting with /api + "/api": { + "target": "", + "ws": true + // ... + }, + // Matches any request starting with /foo + "/foo": { + "target": "", + "ssl": true, + "pathRewrite": { + "^/foo": "/foo/beta" + } + // ... + }, + // Matches /bar/abc.html but not /bar/sub/def.html + "/bar/*.html": { + "target": "", + // ... + }, + // Matches /baz/abc.html and /baz/sub/def.html + "/baz/**/*.html": { + "target": "" + // ... + } + } + // ... +} +``` + +### Configuring a WebSocket Proxy + +When setting up a WebSocket proxy, there are a some extra considerations to be aware of. + +If you’re using a WebSocket engine like [Socket.io](https://socket.io/), you must have a Socket.io server running that you can use as the proxy target. Socket.io will not work with a standard WebSocket server. Specifically, don't expect Socket.io to work with [the websocket.org echo test](http://websocket.org/echo.html). + +There’s some good documentation available for [setting up a Socket.io server](https://socket.io/docs/). + +Standard WebSockets **will** work with a standard WebSocket server as well as the websocket.org echo test. You can use libraries like [ws](https://github.com/websockets/ws) for the server, with [native WebSockets in the browser](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket). + +Either way, you can proxy WebSocket requests manually in `package.json`: + +```js +{ + // ... + "proxy": { + "/socket": { + // Your compatible WebSocket server + "target": "ws://", + // Tell http-proxy-middleware that this is a WebSocket proxy. + // Also allows you to proxy WebSocket requests without an additional HTTP request + // https://github.com/chimurai/http-proxy-middleware#external-websocket-upgrade + "ws": true + // ... + } + } + // ... +} +``` + +## Using HTTPS in Development + +>Note: this feature is available with `react-scripts@0.4.0` and higher. + +You may require the dev server to serve pages over HTTPS. One particular case where this could be useful is when using [the "proxy" feature](#proxying-api-requests-in-development) to proxy requests to an API server when that API server is itself serving HTTPS. + +To do this, set the `HTTPS` environment variable to `true`, then start the dev server as usual with `npm start`: + +#### Windows (cmd.exe) + +```cmd +set HTTPS=true&&npm start +``` + +(Note: the lack of whitespace is intentional.) + +#### Linux, macOS (Bash) + +```bash +HTTPS=true npm start +``` + +Note that the server will use a self-signed certificate, so your web browser will almost definitely display a warning upon accessing the page. + +## Generating Dynamic `` Tags on the Server + +Since Create React App doesn’t support server rendering, you might be wondering how to make `` tags dynamic and reflect the current URL. To solve this, we recommend to add placeholders into the HTML, like this: + +```html + + + + + +``` + +Then, on the server, regardless of the backend you use, you can read `index.html` into memory and replace `__OG_TITLE__`, `__OG_DESCRIPTION__`, and any other placeholders with values depending on the current URL. Just make sure to sanitize and escape the interpolated values so that they are safe to embed into HTML! + +If you use a Node server, you can even share the route matching logic between the client and the server. However duplicating it also works fine in simple cases. + +## Pre-Rendering into Static HTML Files + +If you’re hosting your `build` with a static hosting provider you can use [react-snapshot](https://www.npmjs.com/package/react-snapshot) to generate HTML pages for each route, or relative link, in your application. These pages will then seamlessly become active, or “hydrated”, when the JavaScript bundle has loaded. + +There are also opportunities to use this outside of static hosting, to take the pressure off the server when generating and caching routes. + +The primary benefit of pre-rendering is that you get the core content of each page _with_ the HTML payload—regardless of whether or not your JavaScript bundle successfully downloads. It also increases the likelihood that each route of your application will be picked up by search engines. + +You can read more about [zero-configuration pre-rendering (also called snapshotting) here](https://medium.com/superhighfives/an-almost-static-stack-6df0a2791319). + +## Injecting Data from the Server into the Page + +Similarly to the previous section, you can leave some placeholders in the HTML that inject global variables, for example: + +```js + + + + +``` + +Then, on the server, you can replace `__SERVER_DATA__` with a JSON of real data right before sending the response. The client code can then read `window.SERVER_DATA` to use it. **Make sure to [sanitize the JSON before sending it to the client](https://medium.com/node-security/the-most-common-xss-vulnerability-in-react-js-applications-2bdffbcc1fa0) as it makes your app vulnerable to XSS attacks.** + +## Running Tests + +>Note: this feature is available with `react-scripts@0.3.0` and higher.
+>[Read the migration guide to learn how to enable it in older projects!](https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md#migrating-from-023-to-030) + +Create React App uses [Jest](https://facebook.github.io/jest/) as its test runner. To prepare for this integration, we did a [major revamp](https://facebook.github.io/jest/blog/2016/09/01/jest-15.html) of Jest so if you heard bad things about it years ago, give it another try. + +Jest is a Node-based runner. This means that the tests always run in a Node environment and not in a real browser. This lets us enable fast iteration speed and prevent flakiness. + +While Jest provides browser globals such as `window` thanks to [jsdom](https://github.com/tmpvar/jsdom), they are only approximations of the real browser behavior. Jest is intended to be used for unit tests of your logic and your components rather than the DOM quirks. + +We recommend that you use a separate tool for browser end-to-end tests if you need them. They are beyond the scope of Create React App. + +### Filename Conventions + +Jest will look for test files with any of the following popular naming conventions: + +* Files with `.js` suffix in `__tests__` folders. +* Files with `.test.js` suffix. +* Files with `.spec.js` suffix. + +The `.test.js` / `.spec.js` files (or the `__tests__` folders) can be located at any depth under the `src` top level folder. + +We recommend to put the test files (or `__tests__` folders) next to the code they are testing so that relative imports appear shorter. For example, if `App.test.js` and `App.js` are in the same folder, the test just needs to `import App from './App'` instead of a long relative path. Colocation also helps find tests more quickly in larger projects. + +### Command Line Interface + +When you run `npm test`, Jest will launch in the watch mode. Every time you save a file, it will re-run the tests, just like `npm start` recompiles the code. + +The watcher includes an interactive command-line interface with the ability to run all tests, or focus on a search pattern. It is designed this way so that you can keep it open and enjoy fast re-runs. You can learn the commands from the “Watch Usage” note that the watcher prints after every run: + +![Jest watch mode](http://facebook.github.io/jest/img/blog/15-watch.gif) + +### Version Control Integration + +By default, when you run `npm test`, Jest will only run the tests related to files changed since the last commit. This is an optimization designed to make your tests run fast regardless of how many tests you have. However it assumes that you don’t often commit the code that doesn’t pass the tests. + +Jest will always explicitly mention that it only ran tests related to the files changed since the last commit. You can also press `a` in the watch mode to force Jest to run all tests. + +Jest will always run all tests on a [continuous integration](#continuous-integration) server or if the project is not inside a Git or Mercurial repository. + +### Writing Tests + +To create tests, add `it()` (or `test()`) blocks with the name of the test and its code. You may optionally wrap them in `describe()` blocks for logical grouping but this is neither required nor recommended. + +Jest provides a built-in `expect()` global function for making assertions. A basic test could look like this: + +```js +import sum from './sum'; + +it('sums numbers', () => { + expect(sum(1, 2)).toEqual(3); + expect(sum(2, 2)).toEqual(4); +}); +``` + +All `expect()` matchers supported by Jest are [extensively documented here](http://facebook.github.io/jest/docs/expect.html).
+You can also use [`jest.fn()` and `expect(fn).toBeCalled()`](http://facebook.github.io/jest/docs/expect.html#tohavebeencalled) to create “spies” or mock functions. + +### Testing Components + +There is a broad spectrum of component testing techniques. They range from a “smoke test” verifying that a component renders without throwing, to shallow rendering and testing some of the output, to full rendering and testing component lifecycle and state changes. + +Different projects choose different testing tradeoffs based on how often components change, and how much logic they contain. If you haven’t decided on a testing strategy yet, we recommend that you start with creating simple smoke tests for your components: + +```js +import React from 'react'; +import ReactDOM from 'react-dom'; +import App from './App'; + +it('renders without crashing', () => { + const div = document.createElement('div'); + ReactDOM.render(, div); +}); +``` + +This test mounts a component and makes sure that it didn’t throw during rendering. Tests like this provide a lot value with very little effort so they are great as a starting point, and this is the test you will find in `src/App.test.js`. + +When you encounter bugs caused by changing components, you will gain a deeper insight into which parts of them are worth testing in your application. This might be a good time to introduce more specific tests asserting specific expected output or behavior. + +If you’d like to test components in isolation from the child components they render, we recommend using [`shallow()` rendering API](http://airbnb.io/enzyme/docs/api/shallow.html) from [Enzyme](http://airbnb.io/enzyme/). To install it, run: + +```sh +npm install --save enzyme react-test-renderer +``` + +Alternatively you may use `yarn`: + +```sh +yarn add enzyme react-test-renderer +``` + +You can write a smoke test with it too: + +```js +import React from 'react'; +import { shallow } from 'enzyme'; +import App from './App'; + +it('renders without crashing', () => { + shallow(); +}); +``` + +Unlike the previous smoke test using `ReactDOM.render()`, this test only renders `` and doesn’t go deeper. For example, even if `` itself renders a ` - ); - } -} - -Button.propTypes = { - widthType : React.PropTypes.oneOf(['square', 'auto', 'full']).isRequired, - heightType : React.PropTypes.oneOf(['medium', 'large']).isRequired, - roundedType : React.PropTypes.oneOf(['all', 'bottom']).isRequired, - bgType : React.PropTypes.oneOf(['facebook', 'twitter', 'google-plus', 'pinterest', 'vk', '1', '2', '3']).isRequired, - icon : React.PropTypes.string, - className : React.PropTypes.string, - type : React.PropTypes.oneOf(['button', 'submit', 'reset', 'link', 'text']), - isLoading : React.PropTypes.bool -}; - -Button.defaultProps = { - type : 'button', - isLoading : false -}; diff --git a/src/components/Button/Button.jsx b/src/components/Button/Button.jsx new file mode 100644 index 0000000..cbe9125 --- /dev/null +++ b/src/components/Button/Button.jsx @@ -0,0 +1,83 @@ +import React from 'react'; +import PropTypes from 'prop-types'; + +import './Button.less'; + +const Button = ({ + widthType, + heightType, + roundedType, + bgType, + icon, + className, + type, + disabled, + children, + ...props +}) => { + const widthClassName = `tm-quark-button_width_${widthType}`; + const heightClassName = `tm-quark-button_height_${heightType}`; + const roundClassName = `tm-quark-button_rounded_${roundedType}`; + const bgClassName = disabled ? '' : `tm-quark-button_bg_${bgType}`; + const buttonClassName = (`tm-quark-button ${widthClassName} ${heightClassName} ${roundClassName} ${bgClassName} ${className}`).trim(); + const iconClassName = icon ? `tm-quark-button__icon tm-quark-button__icon-${icon} icon icon-${icon}` : ''; + + const buttonIcon = iconClassName.length > 0 + ? + : null; + const buttonChildren = ( + buttonIcon && children + ); + + if (type === 'link') { + return ( + + {buttonChildren} + + ); + } else if (type === 'text') { + return ( + + {buttonChildren} + + ); + } + + return ( + + ); +}; + +Button.propTypes = { + widthType: PropTypes.oneOf(['square', 'auto', 'full']).isRequired, + heightType: PropTypes.oneOf(['medium', 'large']).isRequired, + roundedType: PropTypes.oneOf(['all', 'bottom']).isRequired, + bgType: PropTypes.oneOf(['facebook', 'twitter', 'google-plus', 'pinterest', 'vk', '1', '2', '3']).isRequired, + icon: PropTypes.string, + className: PropTypes.string, + type: PropTypes.oneOf(['button', 'submit', 'reset', 'link', 'text']), + disabled: PropTypes.bool, + children: PropTypes.node, +}; + +Button.defaultProps = { + icon: '', + className: '', + type: 'button', + disabled: false, + children: null, +}; + +export default Button; diff --git a/src/components/Button.less b/src/components/Button/Button.less similarity index 78% rename from src/components/Button.less rename to src/components/Button/Button.less index ac9e68d..28a28c4 100644 --- a/src/components/Button.less +++ b/src/components/Button/Button.less @@ -1,4 +1,4 @@ -.button { +.tm-quark-button { border: 0; box-sizing: border-box; color: #fff; @@ -56,24 +56,24 @@ vertical-align: top; width: 20px; - .button_width_auto &, - .button_width_full & { + .tm-quark-button_width_auto &, + .tm-quark-button_width_full & { margin-right: 10px; } - .button_height_medium & { + .tm-quark-button_height_medium & { margin-top: 10px; } - .button_height_medium:disabled & { + .tm-quark-button_height_medium:disabled & { margin-top: 8px; } - .button_height_large & { + .tm-quark-button_height_large & { margin-top: 20px; } - .button_height_large:disabled & { + .tm-quark-button_height_large:disabled & { margin-top: 18px; } @@ -84,45 +84,41 @@ left: 0; top: 0; width: 100%; - - .button_loading & { - display: none; - } } &-facebook::before { - background-image: svg-load("../assets/images/icons/icon-facebook.svg", fill: #fff); + background-image: svg-load("../../assets/images/icons/icon-facebook.svg", fill: #fff); } &-google-plus::before { - background-image: svg-load("../assets/images/icons/icon-google-plus.svg", fill: #fff); + background-image: svg-load("../../assets/images/icons/icon-google-plus.svg", fill: #fff); } &-twitter::before { - background-image: svg-load("../assets/images/icons/icon-twitter.svg", fill: #fff); + background-image: svg-load("../../assets/images/icons/icon-twitter.svg", fill: #fff); } &-pinterest::before { - background-image: svg-load("../assets/images/icons/icon-pinterest.svg", fill: #fff); + background-image: svg-load("../../assets/images/icons/icon-pinterest.svg", fill: #fff); } &-vk::before { - background-image: svg-load("../assets/images/icons/icon-vk.svg", fill: #fff); + background-image: svg-load("../../assets/images/icons/icon-vk.svg", fill: #fff); } } - /* .button width */ + /* .tm-quark-button width */ &_width_square { color: rgba(0,0,0,0); - &.button_height_medium { + &.tm-quark-button_height_medium { font-size: 0; width: 40px; } - &.button_height_large { + &.tm-quark-button_height_large { font-size: 0; width: 60px; } @@ -137,15 +133,15 @@ } - /* .button height */ + /* .tm-quark-button height */ &_height_medium { font-size: 14px; height: 40px; line-height: 40px; - &.button_width_auto, - &.button_width_full { + &.tm-quark-button_width_auto, + &.tm-quark-button_width_full { padding-left: 20px; padding-right: 20px; @@ -154,10 +150,6 @@ padding-left: 18px; padding-right: 18px; } - - &.button_loading { - line-height: 0; - } } } @@ -166,8 +158,8 @@ height: 60px; line-height: 60px; - &.button_width_auto, - &.button_width_full { + &.tm-quark-button_width_auto, + &.tm-quark-button_width_full { padding-left: 30px; padding-right: 30px; @@ -176,15 +168,11 @@ padding-left: 28px; padding-right: 28px; } - - &.button_loading { - line-height: 0; - } } } - /* .button rounded */ + /* .tm-quark-button rounded */ &_rounded_all { border-radius: 3px; @@ -198,7 +186,7 @@ } - /* .button bg */ + /* .tm-quark-button bg */ &_bg_1 { background: linear-gradient(to bottom, #f4511e 0%, #d84315 100%); @@ -305,29 +293,21 @@ } - /* .button disabled */ + /* .tm-quark-button disabled */ &:disabled { background: rgba(0, 0, 0, 0); border: 2px solid #b0bec5; cursor: not-allowed; - &:not(.button_width_square) { + &:not(.tm-quark-button_width_square) { color: #b0bec5; } - .button__icon { + .tm-quark-button__icon { &-facebook::before { - background-image: svg-load("../assets/images/icons/icon-facebook.svg", fill: #b0bec5); + background-image: svg-load("../../assets/images/icons/icon-facebook.svg", fill: #b0bec5); } } } - - - /* .button loading */ - - &_loading { - font-size: 0; - vertical-align: middle; - } } diff --git a/src/components/Button/index.js b/src/components/Button/index.js new file mode 100644 index 0000000..627a0a1 --- /dev/null +++ b/src/components/Button/index.js @@ -0,0 +1,2 @@ +export * from './types/'; +export default from './Button'; diff --git a/src/components/Button/types/B1A.jsx b/src/components/Button/types/B1A.jsx new file mode 100644 index 0000000..26bb4e2 --- /dev/null +++ b/src/components/Button/types/B1A.jsx @@ -0,0 +1,15 @@ +import React from 'react'; + +import Button from '../Button'; + +const B1A = props => ( + - )} - - {this.state.open && ( -
{ this.content = ref; }} - > - {this.props.showFilterBox && ( -
{ this.filterBox = ref; }} - > - { this.filterOptions(event.target.value); }} - onKeyDown = {this.handleFilterInputKeyDown} - ref = {(ref) => { this.filterInput = ref; }} - autoFocus - /> -
- )} - -
    { this.optionsList = ref; }} - > - {visibleOptions.length > 0 ? ( - - visibleOptions.map((option, index) => { - if (option.disabled) { - disabledOptionIndex = disabledOptionIndex - 1; - } else { - activeOptionIndex = activeOptionIndex + 1; - } - - const optionIndex = option.disabled ? disabledOptionIndex : activeOptionIndex; - const optionIcon = this.props.optionIconRadioStyle ? 'tm-quark-dropdown__icon tm-quark-dropdown__icon_size_medium tm-quark-dropdown__icon_type_radio' : option.icon ? `tm-quark-dropdown__icon tm-quark-dropdown__icon_size_${this.props.optionIconSize} ${`icon icon-${option.icon}`}` : ''; - - return ( -
  • { this.handleOptionSelect(option); }} - onKeyDown = {(event) => { this.handleOptionKeyDown(event, option, optionIndex); }} - ref = {(ref) => { this[`option${optionIndex}`] = ref; }} - key = {index} - > - {optionIcon.length > 0 && ( - - )} - {option.html || option.label} -
  • - ); - }) - ) : ( - this.state.filterQuery.length > 0 ? ( -
  • - {`${this.props.filterNoResultsText} "${this.state.filterQuery}"`} -
  • - ) : ( - null - ) - )} -
-
- )} - - ); - } -} diff --git a/src/components/Dropdown/Dropdown.jsx b/src/components/Dropdown/Dropdown.jsx new file mode 100644 index 0000000..8f845ca --- /dev/null +++ b/src/components/Dropdown/Dropdown.jsx @@ -0,0 +1,536 @@ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; + +import './Dropdown.less'; + +export default class Dropdown extends Component { + static propTypes = { + id: PropTypes.string, + name: PropTypes.string, + defaultOpen: PropTypes.bool, + closeOnClickOutside: PropTypes.bool, + defaultValue: PropTypes.node, + value: PropTypes.node, + showLabel: PropTypes.bool, + label: PropTypes.string, + showLabelInButton: PropTypes.bool, + labelSize: PropTypes.oneOf([ + 'small', + 'medium', + ]), + showButton: PropTypes.bool, + buttonContent: PropTypes.node, + showOptionHTMLInButton: PropTypes.bool, + buttonSize: PropTypes.oneOf([ + 'medium', + 'large', + ]), + showFilterBox: PropTypes.bool, + defaultFilterQuery: PropTypes.string, + filterBoxPlaceholder: PropTypes.string, + filterNoResultsText: PropTypes.string, + options: PropTypes.arrayOf(PropTypes.object), + optionsToShow: PropTypes.number, + optionSize: PropTypes.oneOf([ + 'medium', + 'large', + ]), + showSelectedOption: PropTypes.bool, + highlightSelectedOption: PropTypes.bool, + optionIconRadioStyle: PropTypes.bool, + optionIconSize: PropTypes.oneOf([ + 'medium', + 'large', + ]), + disabled: PropTypes.bool, + onOpen: PropTypes.func, + onChange: PropTypes.func, + onClose: PropTypes.func, + className: PropTypes.string, + type: PropTypes.oneOf([ + 1, + 2, + 3, + 4, + 5, + 5, + 6, + 7, + ]), + } + + static defaultProps = { + defaultOpen: false, + closeOnClickOutside: true, + showLabel: true, + showLabelInButton: false, + labelSize: 'medium', + showButton: true, + showOptionHTMLInButton: true, + buttonSize: 'medium', + showFilterBox: false, + defaultFilterQuery: '', + filterBoxPlaceholder: '', + filterNoResultsText: 'No results match', + options: [], + optionsToShow: 5, + optionSize: 'medium', + showSelectedOption: true, + highlightSelectedOption: true, + optionIconRadioStyle: false, + optionIconSize: 'medium', + disabled: false, + onOpen: () => {}, + onChange: () => {}, + onClose: () => {}, + buttonContent: null, + label: null, + id: null, + name: null, + defaultValue: null, + value: null, + className: '', + type: 1, + } + + constructor(props) { + super(props); + + const firstOption = this.props.options[0] || {}; + + this.defaultSelectedOption = ( + this.getOptionByValue(this.props.value) + || this.getOptionByValue(this.props.defaultValue) + || firstOption.value + ); + + this.openContentPosition = 'bottom'; + this.optionsListMaxHeight = '100%'; + this.showOptionsListScrollBar = false; + } + + state = { + open: this.props.defaultOpen, + showContent: false, + filterQuery: this.props.defaultFilterQuery, + } + + componentDidMount() { + if (this.props.defaultOpen) { + this.showContent(); + } + } + + componentWillUnmount() { + if (this.state.showContent && this.props.closeOnClickOutside) { + window.removeEventListener('click', this.handleDropdownBlur); + } + } + + getOptionsListMaxHeight = () => { + const options = [...this.optionsList.querySelectorAll('.tm-quark-dropdown__option')]; + + let optionsListHeight = 0; + const lastVisibleOptionIndex = Math.min(options.length - 1, this.props.optionsToShow - 1); + + options.slice(0, lastVisibleOptionIndex + 1).forEach((option, optionIndex) => { + optionsListHeight += ( + lastVisibleOptionIndex === optionIndex + && options.length > + this.props.optionsToShow + ? option.offsetHeight / 2 + : option.offsetHeight + ); + }); + + return optionsListHeight; + } + + getContainerCoordinates = () => { + const documentHeight = Math.max( + document.body.scrollHeight, + document.documentElement.scrollHeight, + document.body.offsetHeight, + document.documentElement.offsetHeight, + document.body.clientHeight, + document.documentElement.clientHeight, + ); + + const containerRect = this.container.getBoundingClientRect(); + const scrollTop = window.pageYOffset || document.documentElement.scrollTop; + + const containerTopOffset = containerRect.top + scrollTop; + const containerBottomOffset = documentHeight - (containerRect.bottom + scrollTop); + + return { + top: containerTopOffset, + bottom: containerBottomOffset, + }; + } + + getFilteredOptions = () => { + const filterQuery = this.state.filterQuery.toLowerCase().trim(); + const filterQueryRegExp = new RegExp(`\\b${filterQuery}`, 'gi'); + + const filteredOptions = this.props.options.filter(option => ( + option.label.search(filterQueryRegExp) >= 0 + )); + + return filteredOptions; + } + + getOptionByValue = (optionValue) => { + if (!optionValue) { + return null; + } + + return this.props.options.find(optionData => ( + optionData.value === optionValue + )); + } + + getValue() { + return this.currentValue; + } + + filterOptions = (filterQuery) => { + this.setState({ + filterQuery, + }); + } + + toggle = () => { + if (this.state.showContent) { + this.close(); + } else { + this.open(); + } + } + + open = () => { + this.setState(() => ({ + open: true, + showContent: false, + }), this.showContent); + } + + showContent = () => { + this.props.onOpen(this.getValue()); + + if (this.props.closeOnClickOutside) { + window.addEventListener('click', this.handleDropdownBlur); + } + + this.setState(() => ({ + open: true, + showContent: true, + })); + } + + close = () => { + if (this.props.closeOnClickOutside) { + window.removeEventListener('click', this.handleDropdownBlur); + } + + this.hideContent(); + } + + hideContent = () => { + this.setState(() => ({ + open: true, + showContent: false, + })); + } + + handleContentAnimationEnd = (event) => { + if (event.target === this.content) { + if (this.state.showContent) { + this.handleShowContentAnimationEnd(); + } else { + this.handleHideContentAnimationEnd(); + } + } + } + + handleShowContentAnimationEnd = () => { + if (this.filterInput) { + this.filterInput.focus(); + } + } + + handleHideContentAnimationEnd = () => { + if (this.button) { + this.button.blur(); + } + + this.setState(() => ({ + open: false, + showContent: false, + }), () => { + if (this.props.onClose) { + this.props.onClose(this.getValue()); + } + }); + } + + handleDropdownBlur = (event) => { + if ( + !this.container.contains(event.target) + && event.target !== this.container + && this.state.showContent + ) { + this.close(); + } + } + + handleContainerKeyDown = (event) => { + const keyCode = event.keyCode; + + if (keyCode === 27) { + this.close(); + } + } + + handleButtonKeyDown = (event) => { + const keyCode = event.keyCode; + + if (keyCode === 40) { + if (this.fileInput) { + this.filterInput.focus(); + } else if (this.option0) { + this.option0.focus(); + } + } + } + + handleFilterInputKeyDown = (event) => { + const keyCode = event.keyCode; + + if (keyCode === 13) { + event.stopPropagation(); + } else if (keyCode === 40 && this.option0) { + this.option0.focus(); + } + } + + handleOptionKeyDown = (event, option, optionIndex) => { + const keyCode = event.keyCode; + + if (keyCode === 13) { + this.handleOptionSelect(option); + } else if (keyCode === 40 && this[`option${optionIndex + 1}`]) { + this[`option${optionIndex + 1}`].focus(); + } else if (keyCode === 38) { + if (this[`option${optionIndex - 1}`] && optionIndex - 1 >= 0) { + this[`option${optionIndex - 1}`].focus(); + } else if (this.filterInput) { + this.filterInput.focus(); + } + } + } + + handleOptionSelect = (option) => { + this.selectedOption = option; + this.currentValue = option.value; + + if (this.props.onChange) { + this.props.onChange(option.value); + } + + this.close(); + } + + render() { + const filteredOptions = this.getFilteredOptions(); + const visibleOptions = this.props.showSelectedOption + ? filteredOptions : + filteredOptions.filter(option => ( + option.value !== this.currentValue + )); + + if (this.state.showContent) { + const containerTopOffset = this.getContainerCoordinates().top; + const containerBottomOffset = this.getContainerCoordinates().bottom; + const optionsListMaxHeight = this.getOptionsListMaxHeight(); + + if (optionsListMaxHeight > (containerBottomOffset - 20)) { + if (containerTopOffset > containerBottomOffset) { + this.showOptionsListScrollBar = ( + (optionsListMaxHeight > (containerTopOffset - 20)) + || (visibleOptions.length > this.props.optionsToShow) + ); + this.optionsListMaxHeight = `${Math.min(optionsListMaxHeight, containerTopOffset - 20)}px`; + this.openContentPosition = 'top'; + } else { + this.showOptionsListScrollBar = true; + this.optionsListMaxHeight = containerBottomOffset - 20; + } + } else { + this.showOptionsListScrollBar = visibleOptions.length > this.props.optionsToShow; + this.optionsListMaxHeight = `${optionsListMaxHeight}px`; + this.openContentPosition = 'bottom'; + } + } + + this.selectedOption = ( + this.getOptionByValue(this.props.value) + || this.getOptionByValue(this.currentValue) + || this.defaultSelectedOption + ); + this.currentValue = this.selectedOption + ? this.selectedOption.value + : null; + + let activeOptionIndex = -1; + let disabledOptionIndex = 0; + + return ( +
{ this.container = ref; }} + role="presentation" + > + {(this.props.showLabelInButton === false && this.props.showLabel) && ( + { this.label = ref; }} + > + {this.props.label} + + )} + + {this.props.showButton && ( + + )} + + {this.state.open && ( +
{ this.content = ref; }} + > + {this.props.showFilterBox && ( +
{ this.filterBox = ref; }} + > + { this.filterOptions(event.target.value); }} + onKeyDown={this.handleFilterInputKeyDown} + ref={(ref) => { this.filterInput = ref; }} + /> +
+ )} + + {this.props.options.length && ( +
    { this.optionsList = ref; }} + > + {visibleOptions.length > 0 ? ( + + visibleOptions.map((option) => { + if (option.disabled) { + disabledOptionIndex -= 1; + } else { + activeOptionIndex += 1; + } + + const optionIconDefaultClassName = option.icon + ? `tm-quark-dropdown__icon tm-quark-dropdown__icon_size_${this.props.optionIconSize} ${`icon icon-${option.icon}`}` + : null; + const optionIconClassName = this.props.optionIconRadioStyle + ? 'tm-quark-dropdown__icon tm-quark-dropdown__icon_size_medium tm-quark-dropdown__icon_type_radio' + : optionIconDefaultClassName; + + const optionIndex = option.disabled ? disabledOptionIndex : activeOptionIndex; + + return ( +
  • { this.handleOptionSelect(option); }} + onKeyDown={(event) => { + this.handleOptionKeyDown(event, option, optionIndex); + }} + ref={(ref) => { this[`option${optionIndex}`] = ref; }} + key={option.value} + role="option" + aria-selected={!option.disabled && option.value === this.currentValue} + > + {optionIconClassName && ( + + )} + {option.html || option.label} +
  • + ); + }) + ) : ( + this.state.filterQuery.length > 0 && ( +
  • + {`${this.props.filterNoResultsText} "${this.state.filterQuery}"`} +
  • + ) + )} +
+ )} +
+ )} +
+ ); + } +} diff --git a/src/components/Dropdown.less b/src/components/Dropdown/Dropdown.less similarity index 99% rename from src/components/Dropdown.less rename to src/components/Dropdown/Dropdown.less index 1637f49..40d00a3 100644 --- a/src/components/Dropdown.less +++ b/src/components/Dropdown/Dropdown.less @@ -182,6 +182,7 @@ &__button { background: linear-gradient(to bottom, #eceff1 0%,#dde3e6 100%); + border: 0; border-radius: 3px; box-shadow: inset 0 -1px 0 0 #cfd8dc; cursor: pointer; diff --git a/src/components/Dropdown/index.js b/src/components/Dropdown/index.js new file mode 100644 index 0000000..f22e194 --- /dev/null +++ b/src/components/Dropdown/index.js @@ -0,0 +1,2 @@ +export * from './types/'; +export default from './Dropdown'; diff --git a/src/components/Dropdown/types/DD1.jsx b/src/components/Dropdown/types/DD1.jsx new file mode 100644 index 0000000..b700036 --- /dev/null +++ b/src/components/Dropdown/types/DD1.jsx @@ -0,0 +1,12 @@ +import React from 'react'; + +import Dropdown from '../Dropdown'; + +const DD1 = props => ( + +); + +export default DD1; diff --git a/src/components/Dropdown/types/DD2.jsx b/src/components/Dropdown/types/DD2.jsx new file mode 100644 index 0000000..812e33d --- /dev/null +++ b/src/components/Dropdown/types/DD2.jsx @@ -0,0 +1,12 @@ +import React from 'react'; + +import Dropdown from '../Dropdown'; + +const DD2 = props => ( + +); + +export default DD2; diff --git a/src/components/Dropdown/types/DD3.jsx b/src/components/Dropdown/types/DD3.jsx new file mode 100644 index 0000000..e89cc40 --- /dev/null +++ b/src/components/Dropdown/types/DD3.jsx @@ -0,0 +1,17 @@ +import React from 'react'; + +import Dropdown from '../Dropdown'; + +const DD3 = props => ( + +); + +export default DD3; diff --git a/src/components/Dropdown/types/DD4.jsx b/src/components/Dropdown/types/DD4.jsx new file mode 100644 index 0000000..5cafeee --- /dev/null +++ b/src/components/Dropdown/types/DD4.jsx @@ -0,0 +1,16 @@ +import React from 'react'; + +import Dropdown from '../Dropdown'; + +const DD4 = props => ( + +); + +export default DD4; diff --git a/src/components/Dropdown/types/DD5.jsx b/src/components/Dropdown/types/DD5.jsx new file mode 100644 index 0000000..3afae4e --- /dev/null +++ b/src/components/Dropdown/types/DD5.jsx @@ -0,0 +1,14 @@ +import React from 'react'; + +import Dropdown from '../Dropdown'; + +const DD5 = props => ( + +); + +export default DD5; diff --git a/src/components/Dropdown/types/DD6.jsx b/src/components/Dropdown/types/DD6.jsx new file mode 100644 index 0000000..3693c25 --- /dev/null +++ b/src/components/Dropdown/types/DD6.jsx @@ -0,0 +1,16 @@ +import React from 'react'; + +import Dropdown from '../Dropdown'; + +const DD6 = props => ( + +); + +export default DD6; diff --git a/src/components/Dropdown/types/DD7.jsx b/src/components/Dropdown/types/DD7.jsx new file mode 100644 index 0000000..8590ebb --- /dev/null +++ b/src/components/Dropdown/types/DD7.jsx @@ -0,0 +1,16 @@ +import React from 'react'; + +import Dropdown from '../Dropdown'; + +const DD7 = props => ( + +); + +export default DD7; diff --git a/src/components/Dropdown/types/index.js b/src/components/Dropdown/types/index.js new file mode 100644 index 0000000..97a0fe4 --- /dev/null +++ b/src/components/Dropdown/types/index.js @@ -0,0 +1,7 @@ +export DD1 from './DD1'; +export DD2 from './DD2'; +export DD3 from './DD3'; +export DD4 from './DD4'; +export DD5 from './DD5'; +export DD6 from './DD6'; +export DD7 from './DD7'; diff --git a/src/components/Field.jsx b/src/components/Field.jsx deleted file mode 100644 index bec6983..0000000 --- a/src/components/Field.jsx +++ /dev/null @@ -1,190 +0,0 @@ -import React, {Component, PropTypes} from 'react'; -import notifications from './notifications/'; - -import './Field.less'; - -export default class Field extends Component { - static propTypes = { - containerClassName : PropTypes.string, - containerId : PropTypes.string, - containerName : PropTypes.string, - size : PropTypes.oneOf(['medium', 'large']).isRequired, - showInputIcon : PropTypes.bool, - icon : PropTypes.string, - className : PropTypes.string, - focused : PropTypes.bool, - showPlaceholderOnInput : PropTypes.bool, - onChange : PropTypes.func, - valid : PropTypes.bool, - invalid : PropTypes.bool, - children : PropTypes.object, - showPasswordFieldTypeToggle : PropTypes.bool, - fieldTypeToggleHint : PropTypes.object, - errorMessage : PropTypes.object - } - - static defaultProps = { - showPlaceholderOnInput : false, - focused : false, - type : 'text', - errorMessage : {} - } - - state = { - isEmpty : this.props.value ? this.props.value.length === 0 : this.props.defaultValue ? this.props.defaultValue.length === 0 : true, - isDirty : false, - fieldType : this.props.type - } - - constructor (props) { - super(props); - - this.handleInputChange = this.handleInputChange.bind(this); - this.setPasswordFieldTypeToText = this.setPasswordFieldTypeToText.bind(this); - this.resetPasswordFieldType = this.resetPasswordFieldType.bind(this); - } - - focus () { - this.input && this.input.focus(); - } - - blur () { - this.input && this.input.blur(); - } - - handleInputChange (event) { - const inputValue = event.target.value; - - this.setState({ - isEmpty : inputValue.length === 0, - isDirty : true - }, () => { - this.props.onChange && this.props.onChange(inputValue); - }); - } - - setPasswordFieldTypeToText (event) { - event.preventDefault(); - - this.setState({ - fieldType: 'text' - }); - } - - resetPasswordFieldType (event) { - event.preventDefault(); - - this.setState({ - fieldType: 'password' - }); - } - - componentWillReceiveProps (nextProps) { - this.setState({ - isEmpty: nextProps.value ? false : this.props.value ? true : this.input.value.length === 0 - }); - } - - componentDidMount () { - this.props.focused && this.focus(); - } - - render () { - const { - containerClassName, - containerId, - containerName, - size, - showInputIcon, - icon, - className, - showPlaceholderOnInput, - valid, - invalid, - showPasswordFieldTypeToggle, - fieldTypeToggleHint, - errorMessage, - focused, - ...inputProps - } = this.props; - - const containerCustomClassName = containerClassName ? ` ${containerClassName}` : ''; - const containerSizeClassName = ` tm-quark-field_size_${size}`; - - const inputSizeClassName = ` tm-quark-field__input_size_${size}`; - const inputValidClassName = valid ? ' tm-quark-field__input_valid' : ''; - const inputInvalidClassName = invalid ? ' tm-quark-field__input_invalid' : ''; - const inputStateClassName = this.state.isEmpty ? ' tm-quark-field__input_empty' : ' tm-quark-field__input_filled'; - const inputDirtyClassName = this.state.isDirty ? ' tm-quark-field__input_dirty' : ''; - const inputCustomClassName = className ? ` ${className}` : ''; - - const fieldIcon = showInputIcon && icon ? icon : showInputIcon && (showInputIcon && (inputProps.type === 'password' || inputProps.type === 'search' || inputProps.type === 'email')) ? inputProps.type : null; - - const inputHasIconClassName = fieldIcon ? ' tm-quark-field__input_with-icon' : ''; - - const FieldErrorMessage = errorMessage && errorMessage.type ? notifications[errorMessage.type] : null; - - if (errorMessage.content) { - this.errorMessageContent = errorMessage.content; - } - - return ( - - ); - } -} diff --git a/src/components/Field.less b/src/components/Field.less deleted file mode 100644 index e1e6640..0000000 --- a/src/components/Field.less +++ /dev/null @@ -1,309 +0,0 @@ -.tm-quark-field { - box-sizing: border-box; - display: flex; - position: relative; - width: 100%; - - *, - *::before, - *::after { - box-sizing: inherit; - } - - &_size { - &_medium { - height: 40px; - } - - &_large { - height: 60px; - } - } - - &__input { - background-color: #eceff1; - border: 1px solid transparent; - box-shadow: inset 0 1px 0 0 #cfd8dc; - border-radius: 3px; - color: #243238; - margin: 0; - padding-left: 19px; - padding-right: 19px; - touch-action: manipulation; - overflow: visible; - width: 100%; - - &[type="number"]::-webkit-inner-spin-button, - &[type="number"]::-webkit-outer-spin-button { - height: auto; - } - - &[type="search"] { - -webkit-appearance: textfield; - outline-offset: -2px; - } - - &[type="search"]::-webkit-search-cancel-button, - &[type="search"]::-webkit-search-decoration { - -webkit-appearance: none; - } - - &::-ms-clear { - display: none; - } - - &::-ms-reveal { - display: none; - } - - &::-webkit-outer-spin-button, - &::-webkit-inner-spin-button { - -webkit-appearance: none; - margin: 0; - } - - &[type=number] { - -moz-appearance: textfield; - appearance: textfield; - } - - &_with-icon { - padding-left: 49px; - } - - &_size { - &_medium { - font-size: 14px; - line-height: 20px; - height: 40px; - padding-top: 9px; - padding-bottom: 9px; - - &::placeholder { - color: #90a4ae; - } - - &:focus::placeholder { - color: #bbdefb; - } - - &:disabled::placeholder { - color: #cfd8dc; - } - } - - &_large { - font-size: 16px; - line-height: 24px; - height: 60px; - padding-top: 17px; - padding-bottom: 17px; - - &::placeholder { - color: transparent; - user-select: none; - } - - &.tm-quark-field__input_filled.tm-quark-field__input_with-label { - padding-top: 26px; - padding-bottom: 10px; - } - } - } - - &_valid, - &_invalid { - padding-right: 49px; - } - - &_valid { - animation: TMQuarkInputMarkValid 1s cubic-bezier(.645, .045, .355, 1); - - @keyframes TMQuarkInputMarkValid { - 25%, 75% { - background-color: #ddf7e5; - box-shadow: inset 0 1px 0 0 #a8e4bb; - border-color: transparent; - } - } - } - - &_invalid { - animation: TMQuarkInputMarkInvalid 1s cubic-bezier(.645, .045, .355, 1); - - @keyframes TMQuarkInputMarkInvalid { - 25%, 75% { - background-color: #fff8e1; - box-shadow: inset 0 1px 0 0 #ffca28; - border-color: transparent; - } - } - } - - &:focus { - background-color: #fff; - border-color: #90caf9; - box-shadow: none; - outline: none; - } - - &:disabled { - background-color: #fff; - border-color: #eceff1; - box-shadow: none; - color: #cfd8dc; - cursor: not-allowed; - } - } - - &__icon { - height: 20px; - position: absolute; - top: 50%; - transform: translateY(-50%); - width: 20px; - - &::before { - background-position: center; - background-repeat: no-repeat; - content: ""; - height: 100%; - left: 50%; - position: absolute; - top: 50%; - transform: translateX(-50%) translateY(-50%); - width: 100%; - } - - &_type { - &_field-type { - left: 20px; - } - - &_validation-status { - animation: TMQuarkInputShowValidationStatusIcon .25s cubic-bezier(.645, .045, .355, 1); - display: none; - right: 20px; - - .tm-quark-field__input_valid ~ &, - .tm-quark-field__input_invalid ~ & { - display: block; - } - - @keyframes TMQuarkInputShowValidationStatusIcon { - from { - opacity: 0; - } - - to { - opacity: 1; - } - } - } - - &_field-type-toggle { - right: 20px; - - .tm-quark-field__input_valid ~ &, - .tm-quark-field__input_invalid ~ & { - right: 50px; - } - } - } - - &_check { - &::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); - } - } - - &_warning { - &::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); - } - } - - &_search, - &_maginifier { - &::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); - } - - .tm-quark-field__input:focus ~ &::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); - } - } - - &_email, - &_letter { - &::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); - } - - .tm-quark-field__input:focus ~ &::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); - } - } - - &_password, - &_key { - &::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); - } - - .tm-quark-field__input:focus ~ &::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); - } - } - - &_user { - &::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); - } - - .tm-quark-field__input:focus ~ &::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); - } - } - - &_eye { - &::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); - } - - &:active::before { - background-image: url("data:image/svg+xml;charset=utf-8,"); - } - } - } - - &__label { - color: #90a4ae; - font-size: 16px; - line-height: 24px; - left: 20px; - pointer-events: none; - position: absolute; - top: 17px; - transition: all .45s cubic-bezier(.23, 1, .32, 1); - - .tm-quark-field__input_with-icon + & { - left: 50px; - } - - .tm-quark-field__input_empty:focus + & { - color: #bbdefb; - } - - .tm-quark-field__input_filled + & { - font-size: 11px; - line-height: 16px; - color: #90a4ae; - top: 10px; - } - - .tm-quark-field__input:disabled + & { - color: #cfd8dc; - } - } -} diff --git a/src/components/Field/Field.jsx b/src/components/Field/Field.jsx new file mode 100644 index 0000000..c372fd1 --- /dev/null +++ b/src/components/Field/Field.jsx @@ -0,0 +1,235 @@ +import React, { Component } from 'react'; +import { PropTypes } from 'prop-types'; +import Icon from '../Icon'; + +import './Field.pcss'; +import ucfirst from '../../utils'; + +export default class Field extends Component { + static propTypes = { + containerClassName: PropTypes.string, + containerId: PropTypes.string, + containerName: PropTypes.string, + size: PropTypes.oneOf(['medium', 'large']).isRequired, + showInputIcon: PropTypes.bool, + icon: PropTypes.string, + className: PropTypes.string, + focused: PropTypes.bool, + showPlaceholderOnInput: PropTypes.bool, + onChange: PropTypes.func, + valid: PropTypes.bool, + invalid: PropTypes.bool, + children: PropTypes.node, + showPasswordFieldTypeToggle: PropTypes.bool, + fieldTypeToggleHint: PropTypes.node, + value: PropTypes.string, + defaultValue: PropTypes.string, + type: PropTypes.string, + disabled: PropTypes.bool, + placeholder: PropTypes.node, + }; + + static defaultProps = { + containerClassName: '', + containerId: null, + containerName: null, + showInputIcon: false, + icon: null, + className: '', + focused: false, + showPlaceholderOnInput: false, + onChange: () => {}, + valid: false, + invalid: false, + children: null, + type: 'text', + showPasswordFieldTypeToggle: false, + fieldTypeToggleHint: null, + value: null, + defaultValue: '', + placeholder: null, + disabled: false, + }; + + state = { + isEmpty: !(this.props.value || this.props.defaultValue), + isDirty: false, + fieldType: this.props.type, + }; + + componentDidMount() { + const { focused } = this.props; + + if (focused) { + this.focus(); + } + } + + componentWillReceiveProps(nextProps) { + const { + value: nextValue, + focused: nextFocused, + } = nextProps; + + const { + value: currentValue, + focused: currentFocused, + } = this.props; + + const isEmpty = ( + !nextValue && !!currentValue + ) || ( + !nextValue && !currentValue && this.input.value.length === 0 + ); + + const isNeedToBeFocued = nextFocused && !currentFocused; + + this.setState(() => ({ + isEmpty, + }), isNeedToBeFocued ? this.focus : null); + } + + setPasswordFieldTypeToText = (event) => { + event.preventDefault(); + + this.setState(() => ({ + fieldType: 'text', + })); + }; + + resetPasswordFieldType = (event) => { + event.preventDefault(); + + this.setState(() => ({ + fieldType: 'password', + })); + }; + + focus = () => { + if (this.input) { + this.input.focus(); + } + }; + + blur = () => { + if (this.input) { + this.input.blur(); + } + }; + + handleInputChange = (event) => { + event.persist(); + + const { onChange } = this.props; + const inputValue = event.target.value; + + this.setState(() => ({ + isEmpty: inputValue.length === 0, + isDirty: true, + }), () => { + onChange(inputValue, event); + }); + }; + + render() { + const { + containerClassName, + containerId, + containerName, + size, + showInputIcon, + icon, + className, + showPlaceholderOnInput, + valid, + invalid, + showPasswordFieldTypeToggle, + fieldTypeToggleHint, + children, + focused, + value, + defaultValue, + type, + disabled, + placeholder, + ...inputProps + } = this.props; + + const containerCustomClassName = containerClassName ? ` ${containerClassName}` : ''; + const containerSizeClassName = ` TMField--size${ucfirst(size)}`; + + const inputSizeClassName = ` TMField__input--size${ucfirst(size)}`; + const inputValidClassName = valid ? ' TMField__input--valid' : ''; + const inputInvalidClassName = invalid ? ' TMField__input--invalid' : ''; + const inputStateClassName = this.state.isEmpty ? ' TMField__input--empty' : ' TMField__input--filled'; + const inputDirtyClassName = this.state.isDirty ? ' TMField__input--dirty' : ''; + const inputCustomClassName = className ? ` ${className}` : ''; + + const fieldTypeIcon = showInputIcon && (type === 'password' || type === 'search' || type === 'email') + ? type + : null; + const fieldIcon = showInputIcon && !!icon + ? icon + : fieldTypeIcon; + + const inputHasIconClassName = fieldIcon ? ' TMField__input--withIcon' : ''; + + return ( + + ); + } +} diff --git a/src/components/Field/Field.pcss b/src/components/Field/Field.pcss new file mode 100644 index 0000000..cccc3ea --- /dev/null +++ b/src/components/Field/Field.pcss @@ -0,0 +1,325 @@ +@import '../../styles/typography.pcss'; + +.TMField { + box-sizing: border-box; + display: flex; + position: relative; + width: 100%; + + *, + *::before, + *::after { + box-sizing: inherit; + } + + &--size { + &Medium { + height: 40px; + } + + &Large { + height: 60px; + } + } + + &__input { + background-color: $color_bg_main; + border: 1px solid transparent; + box-shadow: inset 0 1px 0 0 $color_main_4; + border-radius: 3px; + color: $color_main_10; + margin: 0; + padding-left: 19px; + padding-right: 19px; + touch-action: manipulation; + overflow: visible; + width: 100%; + + ~.TMField__icon--typeFieldType { + fill: $color_main_5; + } + + &[type="number"]::-webkit-inner-spin-button, + &[type="number"]::-webkit-outer-spin-button { + height: auto; + } + + &[type="search"] { + -webkit-appearance: textfield; + outline-offset: -2px; + } + + &[type="search"]::-webkit-search-cancel-button, + &[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; + } + + &::-ms-clear { + display: none; + } + + &::-ms-reveal { + display: none; + } + + &::-webkit-outer-spin-button, + &::-webkit-inner-spin-button { + -webkit-appearance: none; + margin: 0; + } + + &[type=number] { + -moz-appearance: textfield; + appearance: textfield; + } + + &--withIcon { + padding-left: 49px; + } + + &--size { + &Medium { + + @mixin T 3; + height: 40px; + padding-top: 9px; + padding-bottom: 9px; + + &::placeholder { + color: $color_grey_light; + } + + &:focus::placeholder { + color: $color_link_normal_hover_dark; + } + + &:disabled::placeholder { + color: $color_main_4; + } + } + + &Large { + + @mixin T 1; + height: 60px; + padding-top: 17px; + padding-bottom: 17px; + + &::placeholder { + color: transparent; + user-select: none; + } + + &.TMField__input--filled.TMField__input--withLabel { + padding-top: 26px; + padding-bottom: 10px; + } + } + } + + &--valid, + &--invalid { + padding-right: 49px; + } + + &--valid { + animation: TMQuarkInputMarkValid 1s cubic-bezier(.645, .045, .355, 1); + + @keyframes TMQuarkInputMarkValid { + 25%, + 75% { + background-color: $color_success_2; + box-shadow: inset 0 1px 0 0 $color_success_3; + border-color: transparent; + } + } + } + + &--invalid { + animation: TMQuarkInputMarkInvalid 1s cubic-bezier(.645, .045, .355, 1); + + @keyframes TMQuarkInputMarkInvalid { + 25%, + 75% { + background-color: $color_warning_2; + box-shadow: inset 0 1px 0 0 $color_warning_focus; + border-color: transparent; + } + } + } + + &:focus { + background-color: $color_light_main; + border-color: $color_link_normal_dark; + box-shadow: none; + outline: none; + + ~.TMField__icon--typeFieldType { + fill: $color_link_normal_dark; + } + } + + &:disabled { + background-color: $color_light_main; + border-color: $color_main_2; + box-shadow: none; + color: $color_main_4; + cursor: not-allowed; + + ~.TMField__icon--typeFieldType { + fill: $color_main_4; + } + } + } + + &__icon { + height: 20px; + position: absolute; + top: 50%; + transform: translateY(-50%); + width: 20px; + + &::before { + background-position: center; + background-repeat: no-repeat; + content: ""; + height: 100%; + left: 50%; + position: absolute; + top: 50%; + transform: translateX(-50%) translateY(-50%); + width: 100%; + } + + &--type { + &FieldType { + left: 20px; + } + + &ValidationStatus { + animation: TMQuarkInputShowValidationStatusIcon .25s cubic-bezier(.645, .045, .355, 1); + display: none; + right: 20px; + + .TMField__input--valid ~ &, + .TMField__input--invalid ~ & { + display: block; + } + + @keyframes TMQuarkInputShowValidationStatusIcon { + from { + opacity: 0; + } + + to { + opacity: 1; + } + } + } + + &FieldTypeToggle { + right: 20px; + + .TMField__input--valid ~ &, + .TMField__input--invalid ~ & { + right: 50px; + } + } + } + + &--check { + &::before { + background-image: url("data:image/svg+xml;charset=utf-8, "); + } + } + + &--warning { + &::before { + background-image: url("data:image/svg+xml;charset=utf-8, "); + } + } + + &--search, + &--maginifier { + &::before { + background-image: url("data:image/svg+xml;charset=utf-8, "); + } + + .TMField__input:focus ~ &::before { + background-image: url("data:image/svg+xml;charset=utf-8, "); + } + } + + &--email, + &--letter { + &::before { + background-image: url("data:image/svg+xml;charset=utf-8, "); + } + + .TMField__input:focus ~ &::before { + background-image: url("data:image/svg+xml;charset=utf-8, "); + } + } + + &--password, + &--key { + &::before { + background-image: url("data:image/svg+xml;charset=utf-8, "); + } + + .TMField__input:focus ~ &::before { + background-image: url("data:image/svg+xml;charset=utf-8, "); + } + } + + &--user { + &::before { + background-image: url("data:image/svg+xml;charset=utf-8, "); + } + + .TMField__input:focus ~ &::before { + background-image: url("data:image/svg+xml;charset=utf-8, "); + } + } + + &--eye { + &::before { + background-image: url("data:image/svg+xml;charset=utf-8, "); + } + + &:active::before { + background-image: url("data:image/svg+xml;charset=utf-8, "); + } + } + } + + &__label { + + @mixin T 1; + color: $color_main_6; + left: 20px; + pointer-events: none; + position: absolute; + top: 17px; + transition: all .45s cubic-bezier(.23, 1, .32, 1); + + .TMField__input--withIcon + & { + left: 50px; + } + + .TMField__input--empty:focus + & { + color: $color_link_normal_hover_dark; + } + + .TMField__input--filled + & { + + @mixin T 6; + color: $color_main_top; + top: 10px; + } + + .TMField__input:disabled + & { + color: $color_main_4; + } + } +} diff --git a/src/components/Field/index.js b/src/components/Field/index.js new file mode 100644 index 0000000..15b2f04 --- /dev/null +++ b/src/components/Field/index.js @@ -0,0 +1,2 @@ +export * from './types/'; +export default from './Field'; diff --git a/src/components/Field/types/F1.jsx b/src/components/Field/types/F1.jsx new file mode 100644 index 0000000..48422ca --- /dev/null +++ b/src/components/Field/types/F1.jsx @@ -0,0 +1,12 @@ +import React from 'react'; + +import Field from '../Field'; + +const F1 = props => ( + +); + +export default F1; diff --git a/src/components/Field/types/F2.jsx b/src/components/Field/types/F2.jsx new file mode 100644 index 0000000..96541ce --- /dev/null +++ b/src/components/Field/types/F2.jsx @@ -0,0 +1,13 @@ +import React from 'react'; + +import Field from '../Field'; + +const F2 = props => ( + +); + +export default F2; diff --git a/src/components/Field/types/F3.jsx b/src/components/Field/types/F3.jsx new file mode 100644 index 0000000..611fa19 --- /dev/null +++ b/src/components/Field/types/F3.jsx @@ -0,0 +1,13 @@ +import React from 'react'; + +import Field from '../Field'; + +const F3 = props => ( + +); + +export default F3; diff --git a/src/components/Field/types/F4.jsx b/src/components/Field/types/F4.jsx new file mode 100644 index 0000000..99ba203 --- /dev/null +++ b/src/components/Field/types/F4.jsx @@ -0,0 +1,14 @@ +import React from 'react'; + +import Field from '../Field'; + +const F4 = props => ( + +); + +export default F4; diff --git a/src/components/Field/types/index.js b/src/components/Field/types/index.js new file mode 100644 index 0000000..5e23179 --- /dev/null +++ b/src/components/Field/types/index.js @@ -0,0 +1,4 @@ +export F1 from './F1'; +export F2 from './F2'; +export F3 from './F3'; +export F4 from './F4'; diff --git a/src/components/Icon/index.jsx b/src/components/Icon/Icon.jsx similarity index 77% rename from src/components/Icon/index.jsx rename to src/components/Icon/Icon.jsx index a42a757..a7dca68 100644 --- a/src/components/Icon/index.jsx +++ b/src/components/Icon/Icon.jsx @@ -31,11 +31,11 @@ const Icon = ({ viewBox, width, height, icon, className }) => ( * @type {Object} */ Icon.propTypes = { - icon : PropTypes.string.isRequired, - className : PropTypes.string, - viewBox : PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), - width : PropTypes.number, - height : PropTypes.number + icon: PropTypes.string.isRequired, + className: PropTypes.string, + viewBox: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), + width: PropTypes.number, + height: PropTypes.number, }; /** @@ -45,10 +45,10 @@ Icon.propTypes = { * @type {Object} */ Icon.defaultProps = { - className : '', - width : 20, - height : 20, - viewBox : false + className: '', + width: 20, + height: 20, + viewBox: false, }; export default Icon; diff --git a/src/components/Icon/index.js b/src/components/Icon/index.js new file mode 100644 index 0000000..3680ed0 --- /dev/null +++ b/src/components/Icon/index.js @@ -0,0 +1 @@ +export default from './Icon'; diff --git a/src/components/Loader.jsx b/src/components/Loader.jsx deleted file mode 100644 index 99ee317..0000000 --- a/src/components/Loader.jsx +++ /dev/null @@ -1,26 +0,0 @@ -import React from 'react'; - -import './Loader.less'; - -export default class Loader extends React.Component { - static propTypes = { - width : React.PropTypes.oneOf(['fixed', 'full']).isRequired, - height : React.PropTypes.oneOf(['medium', 'large']).isRequired, - className : React.PropTypes.string - } - - render () { - const addClassName = this.props.className ? ` ${this.props.className}` : ''; - const widthClassName = ` loader_width_${this.props.width}`; - const heightClassName = ` loader_height_${this.props.height}`; - const fullClassName = `loader${widthClassName}${heightClassName}${addClassName}`; - - return ( - - - - - - ); - } -} diff --git a/src/components/Loader/Loader.jsx b/src/components/Loader/Loader.jsx new file mode 100644 index 0000000..50f60da --- /dev/null +++ b/src/components/Loader/Loader.jsx @@ -0,0 +1,28 @@ +import React from 'react'; +import PropTypes from 'prop-types'; + +import './Loader.less'; + +const Loader = ({ + width, + height, + className, +}) => ( + + + + + +); + +Loader.propTypes = { + width: PropTypes.oneOf(['fixed', 'full']).isRequired, + height: PropTypes.oneOf(['medium', 'large']).isRequired, + className: PropTypes.string, +}; + +Loader.defaultProps = { + className: '', +}; + +export default Loader; diff --git a/src/components/Loader.less b/src/components/Loader/Loader.less similarity index 92% rename from src/components/Loader.less rename to src/components/Loader/Loader.less index ad92985..08ae862 100644 --- a/src/components/Loader.less +++ b/src/components/Loader/Loader.less @@ -1,4 +1,4 @@ -.loader { +.tm-quark-loader { box-sizing: border-box; display: inline-block; position: relative; @@ -10,9 +10,6 @@ box-sizing: border-box; } - - /* .loadre modes */ - &_width_full { width: 100%; } @@ -29,10 +26,7 @@ height: 8px; } - - /* .loader__line */ - - .loader__line { + &__line { animation-name: loaderLineMove; animation-duration: 2s; animation-iteration-count: infinite; diff --git a/src/components/Loader/index.js b/src/components/Loader/index.js new file mode 100644 index 0000000..93cfbf5 --- /dev/null +++ b/src/components/Loader/index.js @@ -0,0 +1,2 @@ +export * from './types/'; +export default from './Loader'; diff --git a/src/components/Loader/types/L1.jsx b/src/components/Loader/types/L1.jsx new file mode 100644 index 0000000..879ca48 --- /dev/null +++ b/src/components/Loader/types/L1.jsx @@ -0,0 +1,13 @@ +import React from 'react'; + +import Loader from '../Loader'; + +const L1 = props => ( + +); + +export default L1; diff --git a/src/components/Loader/types/L2.jsx b/src/components/Loader/types/L2.jsx new file mode 100644 index 0000000..3df655d --- /dev/null +++ b/src/components/Loader/types/L2.jsx @@ -0,0 +1,13 @@ +import React from 'react'; + +import Loader from '../Loader'; + +const L2 = props => ( + +); + +export default L2; diff --git a/src/components/Loader/types/L3.jsx b/src/components/Loader/types/L3.jsx new file mode 100644 index 0000000..d1c1088 --- /dev/null +++ b/src/components/Loader/types/L3.jsx @@ -0,0 +1,13 @@ +import React from 'react'; + +import Loader from '../Loader'; + +const L3 = props => ( + +); + +export default L3; diff --git a/src/components/Loader/types/L4.jsx b/src/components/Loader/types/L4.jsx new file mode 100644 index 0000000..e0b57dd --- /dev/null +++ b/src/components/Loader/types/L4.jsx @@ -0,0 +1,13 @@ +import React from 'react'; + +import Loader from '../Loader'; + +const L4 = props => ( + +); + +export default L4; diff --git a/src/components/Loader/types/index.js b/src/components/Loader/types/index.js new file mode 100644 index 0000000..c991095 --- /dev/null +++ b/src/components/Loader/types/index.js @@ -0,0 +1,4 @@ +export L1 from './L1'; +export L2 from './L2'; +export L3 from './L3'; +export L4 from './L4'; diff --git a/src/components/Notification.jsx b/src/components/Notification.jsx deleted file mode 100644 index 8b49657..0000000 --- a/src/components/Notification.jsx +++ /dev/null @@ -1,154 +0,0 @@ -import React, {Component, PropTypes} from 'react'; - -import './Notification.less'; - -export default class Notification extends Component { - static propTypes = { - onRequestHide : PropTypes.func, - position : PropTypes.oneOf([ - 'absolute', - 'fixed', - 'relative']).isRequired, - placement: PropTypes.oneOf([ - 'bottom', - 'left', - 'top', - 'right', - 'static', - 'document-top', - 'document-right' - ]).isRequired, - height: PropTypes.oneOf([ - 'auto', - 'fixed-small', - 'fixed-medium' - ]).isRequired, - width: PropTypes.oneOf([ - 'auto', - 'full' - ]).isRequired, - type: PropTypes.oneOf([ - 'default', - 'success', - 'warning', - 'error' - ]).isRequired, - show : PropTypes.bool, - className : PropTypes.string, - showArrow : PropTypes.bool, - arrowPlacement : PropTypes.oneOf([ - 'bottom', - 'left', - 'top', - 'right' - ]).isRequired, - showCloseBtn : PropTypes.bool, - hideOnClickOutside : PropTypes.bool - } - - static defaultProps = { - onRequestHide : () => {}, - show : false, - showArrow : true, - showCloseBtn : false, - hideOnClickOutside : true, - className : '' - } - - state = { - renderContainer: this.props.show - } - - constructor (props) { - super(props); - - this.handleAnimationEnd = this.handleAnimationEnd.bind(this); - this.handleClickOutside = this.handleClickOutside.bind(this); - this.removeContainer = this.removeContainer.bind(this); - } - - handleAnimationEnd (event) { - if (event.target === this.container && !this.props.show) { - window.removeEventListener('click', this.handleClickOutside); - - this.removeContainer(); - } else { - window.addEventListener('click', this.handleClickOutside); - } - } - - handleClickOutside (event) { - if (this.props.hideOnClickOutside && this.container && event.target !== this.container && !this.container.contains(event.target) && this.props.show) { - this.props.onRequestHide(); - } - } - - removeContainer () { - this.setState({ - renderContainer: false - }); - } - - componentWillReceiveProps (nextProps) { - if (nextProps.show && !this.state.renderContainer) { - this.setState({ - renderContainer: true - }); - } - } - - render () { - const { - onRequestHide, - position, - placement, - height, - width, - type, - showArrow, - arrowPlacement, - showCloseBtn, - className, - hideOnClickOutside, - show, - children, - ...notificationProps - } = this.props; - - const notificationPositionClassName = `tm-quark-notification_position_${position}`; - const notificationShowAtClassName = `tm-quark-notification_placement_${placement}`; - const notificationHeightClassName = `tm-quark-notification_height_${height}`; - const notificationWidthClassName = `tm-quark-notification_width_${width}`; - const notificationTypeClassName = `tm-quark-notification_type_${type}`; - const notificationArrowClassName = showArrow ? `tm-quark-notification_arrow-placement_${arrowPlacement}` : ''; - const notificationStateClassName = `tm-quark-notification_${show ? 'visible' : 'hidden'}`; - - return ( - this.state.renderContainer ? ( -
{ this.container = ref; }} - > - {showCloseBtn && ( - - )} - -
- {children} -
-
- ) : ( - null - ) - ); - } -} diff --git a/src/components/Notification/Notification.jsx b/src/components/Notification/Notification.jsx new file mode 100644 index 0000000..bf5b8b4 --- /dev/null +++ b/src/components/Notification/Notification.jsx @@ -0,0 +1,158 @@ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; + +import './Notification.less'; + +export default class Notification extends Component { + static propTypes = { + onRequestHide: PropTypes.func, + position: PropTypes.oneOf([ + 'absolute', + 'fixed', + 'relative']).isRequired, + placement: PropTypes.oneOf([ + 'bottom', + 'left', + 'top', + 'right', + 'static', + 'document-top', + 'document-right', + ]).isRequired, + height: PropTypes.oneOf([ + 'auto', + 'fixed-small', + 'fixed-medium', + ]).isRequired, + width: PropTypes.oneOf([ + 'auto', + 'full', + ]).isRequired, + type: PropTypes.oneOf([ + 'default', + 'success', + 'warning', + 'error', + ]).isRequired, + show: PropTypes.bool, + className: PropTypes.string, + showArrow: PropTypes.bool, + arrowPlacement: PropTypes.oneOf([ + 'bottom', + 'left', + 'top', + 'right', + ]).isRequired, + showCloseBtn: PropTypes.bool, + hideOnClickOutside: PropTypes.bool, + children: PropTypes.node, + } + + static defaultProps = { + onRequestHide: () => {}, + show: false, + showArrow: true, + showCloseBtn: false, + hideOnClickOutside: true, + className: '', + children: null, + } + + state = { + renderContainer: this.props.show, + } + + componentWillReceiveProps(nextProps) { + if (nextProps.show && !this.state.renderContainer) { + this.setState({ + renderContainer: true, + }); + } + } + + componentWillUnmount() { + window.removeEventListener('click', this.handleClickOutside); + } + + handleAnimationEnd = (event) => { + if (event.target === this.container && !this.props.show) { + window.removeEventListener('click', this.handleClickOutside); + + this.removeContainer(); + } else { + window.addEventListener('click', this.handleClickOutside); + } + } + + handleClickOutside = (event) => { + if ( + this.props.hideOnClickOutside + && this.container + && event.target !== this.container + && !this.container.contains(event.target) + && this.props.show + ) { + this.props.onRequestHide(); + } + } + + removeContainer = () => { + this.setState({ + renderContainer: false, + }); + } + + render() { + const { + onRequestHide, + position, + placement, + height, + width, + type, + showArrow, + arrowPlacement, + showCloseBtn, + className, + hideOnClickOutside, + show, + children, + ...notificationProps + } = this.props; + + const notificationPositionClassName = `tm-quark-notification_position_${position}`; + const notificationShowAtClassName = `tm-quark-notification_placement_${placement}`; + const notificationHeightClassName = `tm-quark-notification_height_${height}`; + const notificationWidthClassName = `tm-quark-notification_width_${width}`; + const notificationTypeClassName = `tm-quark-notification_type_${type}`; + const notificationArrowClassName = showArrow ? `tm-quark-notification_arrow-placement_${arrowPlacement}` : ''; + const notificationStateClassName = `tm-quark-notification_${show ? 'visible' : 'hidden'}`; + + return ( + this.state.renderContainer ? ( +
{ this.container = ref; }} + > + {showCloseBtn && ( +
+ ) : ( + null + ) + ); + } +} diff --git a/src/components/Notification.less b/src/components/Notification/Notification.less similarity index 93% rename from src/components/Notification.less rename to src/components/Notification/Notification.less index 8d7a638..d1eb308 100644 --- a/src/components/Notification.less +++ b/src/components/Notification/Notification.less @@ -5,6 +5,7 @@ color: #fff; padding-left: 20px; padding-right: 20px; + z-index: 2; *, *::before, @@ -48,7 +49,7 @@ left: 0; &.tm-quark-notification_visible { - animation: TMQuarkNotificationShowToLeft .5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; + animation: TMQuarkNotificationShowToLeft .5s cubic-bezier(.68, -.55, .265, 1.55) forwards; @keyframes TMQuarkNotificationShowToLeft { from { @@ -66,7 +67,7 @@ } &.tm-quark-notification_hidden { - animation: TMQuarkNotificationHideFromLeft .5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; + animation: TMQuarkNotificationHideFromLeft .5s cubic-bezier(.68, -.55, .265, 1.55) forwards; @keyframes TMQuarkNotificationHideFromLeft { from { @@ -88,7 +89,7 @@ top: 0; &.tm-quark-notification_visible { - animation: TMQuarkNotificationShowToTop .5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; + animation: TMQuarkNotificationShowToTop .5s cubic-bezier(.68, -.55, .265, 1.55) forwards; @keyframes TMQuarkNotificationShowToTop { from { @@ -106,7 +107,7 @@ } &.tm-quark-notification_hidden { - animation: TMQuarkNotificationHideFromTop .5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; + animation: TMQuarkNotificationHideFromTop .5s cubic-bezier(.68, -.55, .265, 1.55) forwards; @keyframes TMQuarkNotificationHideFromTop { from { @@ -128,7 +129,7 @@ bottom: 0; &.tm-quark-notification_visible { - animation: TMQuarkNotificationShowToBottom .5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; + animation: TMQuarkNotificationShowToBottom .5s cubic-bezier(.68, -.55, .265, 1.55) forwards; @keyframes TMQuarkNotificationShowToBottom { from { @@ -146,7 +147,7 @@ } &.tm-quark-notification_hidden { - animation: TMQuarkNotificationHideFromBottom .5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; + animation: TMQuarkNotificationHideFromBottom .5s cubic-bezier(.68, -.55, .265, 1.55) forwards; @keyframes TMQuarkNotificationHideFromBottom { from { @@ -168,7 +169,7 @@ right: 0; &.tm-quark-notification_visible { - animation: TMQuarkNotificationShowToRight .5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; + animation: TMQuarkNotificationShowToRight .5s cubic-bezier(.68, -.55, .265, 1.55) forwards; @keyframes TMQuarkNotificationShowToRight { from { @@ -186,7 +187,7 @@ } &.tm-quark-notification_hidden { - animation: TMQuarkNotificationHideFromRight .5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; + animation: TMQuarkNotificationHideFromRight .5s cubic-bezier(.68, -.55, .265, 1.55) forwards; @keyframes TMQuarkNotificationHideFromRight { from { @@ -215,10 +216,12 @@ } &_fixed-medium { + font-size: 13px; height: 60px; } &_auto { + font-size: 13px; padding-bottom: 20px; padding-top: 20px; } @@ -234,7 +237,7 @@ &_success { color: #1ab744; background-color: #1ab744; - box-shadow: 0 5px 10px 0 rgba(0, 96, 35, 0.2); + box-shadow: 0 5px 10px 0 rgba(0, 96, 35, .2); } &_error { @@ -299,7 +302,6 @@ &__content { color: #fff; - position: relative; white-space: nowrap; width: 100%; } diff --git a/src/components/Notification/index.js b/src/components/Notification/index.js new file mode 100644 index 0000000..32683d9 --- /dev/null +++ b/src/components/Notification/index.js @@ -0,0 +1,2 @@ +export * from './types/'; +export default from './Notification'; diff --git a/src/components/Notification/types/N1A.jsx b/src/components/Notification/types/N1A.jsx new file mode 100644 index 0000000..e4834dd --- /dev/null +++ b/src/components/Notification/types/N1A.jsx @@ -0,0 +1,17 @@ +import React from 'react'; + +import Notification from '../Notification'; + +const N1A = props => ( + +); + +export default N1A; diff --git a/src/components/Notification/types/N1B.jsx b/src/components/Notification/types/N1B.jsx new file mode 100644 index 0000000..f07a3a2 --- /dev/null +++ b/src/components/Notification/types/N1B.jsx @@ -0,0 +1,17 @@ +import React from 'react'; + +import Notification from '../Notification'; + +const N1B = props => ( + +); + +export default N1B; diff --git a/src/components/Notification/types/N1C.jsx b/src/components/Notification/types/N1C.jsx new file mode 100644 index 0000000..33232ef --- /dev/null +++ b/src/components/Notification/types/N1C.jsx @@ -0,0 +1,17 @@ +import React from 'react'; + +import Notification from '../Notification'; + +const N1C = props => ( + +); + +export default N1C; diff --git a/src/components/Notification/types/N1D.jsx b/src/components/Notification/types/N1D.jsx new file mode 100644 index 0000000..58a2fa1 --- /dev/null +++ b/src/components/Notification/types/N1D.jsx @@ -0,0 +1,17 @@ +import React from 'react'; + +import Notification from '../Notification'; + +const N1D = props => ( + +); + +export default N1D; diff --git a/src/components/Notification/types/N1E.jsx b/src/components/Notification/types/N1E.jsx new file mode 100644 index 0000000..43fc841 --- /dev/null +++ b/src/components/Notification/types/N1E.jsx @@ -0,0 +1,17 @@ +import React from 'react'; + +import Notification from '../Notification'; + +const N1E = props => ( + +); + +export default N1E; diff --git a/src/components/Notification/types/N1F.jsx b/src/components/Notification/types/N1F.jsx new file mode 100644 index 0000000..1e25606 --- /dev/null +++ b/src/components/Notification/types/N1F.jsx @@ -0,0 +1,17 @@ +import React from 'react'; + +import Notification from '../Notification'; + +const N1F = props => ( + +); + +export default N1F; diff --git a/src/components/Notification/types/N1G.jsx b/src/components/Notification/types/N1G.jsx new file mode 100644 index 0000000..576e5c8 --- /dev/null +++ b/src/components/Notification/types/N1G.jsx @@ -0,0 +1,17 @@ +import React from 'react'; + +import Notification from '../Notification'; + +const N1G = props => ( + +); + +export default N1G; diff --git a/src/components/Notification/types/N1I.jsx b/src/components/Notification/types/N1I.jsx new file mode 100644 index 0000000..dc60a59 --- /dev/null +++ b/src/components/Notification/types/N1I.jsx @@ -0,0 +1,17 @@ +import React from 'react'; + +import Notification from '../Notification'; + +const N1I = props => ( + +); + +export default N1I; diff --git a/src/components/Notification/types/N1J.jsx b/src/components/Notification/types/N1J.jsx new file mode 100644 index 0000000..f737045 --- /dev/null +++ b/src/components/Notification/types/N1J.jsx @@ -0,0 +1,18 @@ +import React from 'react'; + +import Notification from '../Notification'; + +const N1J = props => ( + +); + +export default N1J; diff --git a/src/components/Notification/types/N2A.jsx b/src/components/Notification/types/N2A.jsx new file mode 100644 index 0000000..5337e92 --- /dev/null +++ b/src/components/Notification/types/N2A.jsx @@ -0,0 +1,17 @@ +import React from 'react'; + +import Notification from '../Notification'; + +const N2A = props => ( + +); + +export default N2A; diff --git a/src/components/Notification/types/N2B.jsx b/src/components/Notification/types/N2B.jsx new file mode 100644 index 0000000..a6eae0c --- /dev/null +++ b/src/components/Notification/types/N2B.jsx @@ -0,0 +1,17 @@ +import React from 'react'; + +import Notification from '../Notification'; + +const N2B = props => ( + +); + +export default N2B; diff --git a/src/components/Notification/types/N2C.jsx b/src/components/Notification/types/N2C.jsx new file mode 100644 index 0000000..579f22f --- /dev/null +++ b/src/components/Notification/types/N2C.jsx @@ -0,0 +1,17 @@ +import React from 'react'; + +import Notification from '../Notification'; + +const N2C = props => ( + +); + +export default N2C; diff --git a/src/components/Notification/types/N2D.jsx b/src/components/Notification/types/N2D.jsx new file mode 100644 index 0000000..83956c8 --- /dev/null +++ b/src/components/Notification/types/N2D.jsx @@ -0,0 +1,17 @@ +import React from 'react'; + +import Notification from '../Notification'; + +const N2D = props => ( + +); + +export default N2D; diff --git a/src/components/Notification/types/N2E.jsx b/src/components/Notification/types/N2E.jsx new file mode 100644 index 0000000..f0a5388 --- /dev/null +++ b/src/components/Notification/types/N2E.jsx @@ -0,0 +1,17 @@ +import React from 'react'; + +import Notification from '../Notification'; + +const N2E = props => ( + +); + +export default N2E; diff --git a/src/components/Notification/types/N2F.jsx b/src/components/Notification/types/N2F.jsx new file mode 100644 index 0000000..e846745 --- /dev/null +++ b/src/components/Notification/types/N2F.jsx @@ -0,0 +1,17 @@ +import React from 'react'; + +import Notification from '../Notification'; + +const N2F = props => ( + +); + +export default N2F; diff --git a/src/components/Notification/types/N2G.jsx b/src/components/Notification/types/N2G.jsx new file mode 100644 index 0000000..80cbaa4 --- /dev/null +++ b/src/components/Notification/types/N2G.jsx @@ -0,0 +1,17 @@ +import React from 'react'; + +import Notification from '../Notification'; + +const N2G = props => ( + +); + +export default N2G; diff --git a/src/components/Notification/types/N2I.jsx b/src/components/Notification/types/N2I.jsx new file mode 100644 index 0000000..5662760 --- /dev/null +++ b/src/components/Notification/types/N2I.jsx @@ -0,0 +1,17 @@ +import React from 'react'; + +import Notification from '../Notification'; + +const N2I = props => ( + +); + +export default N2I; diff --git a/src/components/Notification/types/N3A.jsx b/src/components/Notification/types/N3A.jsx new file mode 100644 index 0000000..6c41203 --- /dev/null +++ b/src/components/Notification/types/N3A.jsx @@ -0,0 +1,17 @@ +import React from 'react'; + +import Notification from '../Notification'; + +const N3A = props => ( + +); + +export default N3A; diff --git a/src/components/Notification/types/N3B.jsx b/src/components/Notification/types/N3B.jsx new file mode 100644 index 0000000..e14f38f --- /dev/null +++ b/src/components/Notification/types/N3B.jsx @@ -0,0 +1,17 @@ +import React from 'react'; + +import Notification from '../Notification'; + +const N3B = props => ( + +); + +export default N3B; diff --git a/src/components/Notification/types/N3C.jsx b/src/components/Notification/types/N3C.jsx new file mode 100644 index 0000000..fd234ec --- /dev/null +++ b/src/components/Notification/types/N3C.jsx @@ -0,0 +1,17 @@ +import React from 'react'; + +import Notification from '../Notification'; + +const N3C = props => ( + +); + +export default N3C; diff --git a/src/components/Notification/types/N3D.jsx b/src/components/Notification/types/N3D.jsx new file mode 100644 index 0000000..037fc2b --- /dev/null +++ b/src/components/Notification/types/N3D.jsx @@ -0,0 +1,17 @@ +import React from 'react'; + +import Notification from '../Notification'; + +const N3D = props => ( + +); + +export default N3D; diff --git a/src/components/Notification/types/N3E.jsx b/src/components/Notification/types/N3E.jsx new file mode 100644 index 0000000..f026dd3 --- /dev/null +++ b/src/components/Notification/types/N3E.jsx @@ -0,0 +1,17 @@ +import React from 'react'; + +import Notification from '../Notification'; + +const N3E = props => ( + +); + +export default N3E; diff --git a/src/components/Notification/types/N3F.jsx b/src/components/Notification/types/N3F.jsx new file mode 100644 index 0000000..e324021 --- /dev/null +++ b/src/components/Notification/types/N3F.jsx @@ -0,0 +1,17 @@ +import React from 'react'; + +import Notification from '../Notification'; + +const N3F = props => ( + +); + +export default N3F; diff --git a/src/components/Notification/types/N3G.jsx b/src/components/Notification/types/N3G.jsx new file mode 100644 index 0000000..48c025a --- /dev/null +++ b/src/components/Notification/types/N3G.jsx @@ -0,0 +1,17 @@ +import React from 'react'; + +import Notification from '../Notification'; + +const N3G = props => ( + +); + +export default N3G; diff --git a/src/components/Notification/types/N3I.jsx b/src/components/Notification/types/N3I.jsx new file mode 100644 index 0000000..5d93976 --- /dev/null +++ b/src/components/Notification/types/N3I.jsx @@ -0,0 +1,17 @@ +import React from 'react'; + +import Notification from '../Notification'; + +const N3I = props => ( + +); + +export default N3I; diff --git a/src/components/Notification/types/index.js b/src/components/Notification/types/index.js new file mode 100644 index 0000000..048a2ef --- /dev/null +++ b/src/components/Notification/types/index.js @@ -0,0 +1,27 @@ +export N1A from './N1A'; +export N1B from './N1B'; +export N1C from './N1C'; +export N1D from './N1D'; +export N1E from './N1E'; +export N1F from './N1F'; +export N1G from './N1G'; +export N1I from './N1I'; +export N1J from './N1J'; + +export N2A from './N2A'; +export N2B from './N2B'; +export N2C from './N2C'; +export N2D from './N2D'; +export N2E from './N2E'; +export N2F from './N2F'; +export N2G from './N2G'; +export N2I from './N2I'; + +export N3A from './N3A'; +export N3B from './N3B'; +export N3C from './N3C'; +export N3D from './N3D'; +export N3E from './N3E'; +export N3F from './N3F'; +export N3G from './N3G'; +export N3I from './N3I'; diff --git a/src/components/Popup.jsx b/src/components/Popup.jsx deleted file mode 100644 index 63fb003..0000000 --- a/src/components/Popup.jsx +++ /dev/null @@ -1,106 +0,0 @@ -import React from 'react'; - -import './Popup.less'; - -export default class Popup extends React.Component { - static propTypes = { - open : React.PropTypes.bool.isRequired, - bg : React.PropTypes.oneOf(['transparent', 'fill']).isRequired, - padding : React.PropTypes.oneOf(['none', 'medium', 'large']).isRequired, - closeText : React.PropTypes.string.isRequired, - onRequestClose : React.PropTypes.func.isRequired, - className : React.PropTypes.string, - id : React.PropTypes.string - } - - constructor (props) { - super(props); - - this.closePopupOnEsc = this.closePopupOnEsc.bind(this); - this.animateClose = this.animateClose.bind(this); - this.close = this.close.bind(this); - } - - close () { - this.content.removeEventListener('animationend', this.close); - document.body.style.removeProperty('overflow'); - this.props.onRequestClose(); - } - - animateClose () { - this.content.classList.add('popup__content_animate_hide'); - this.content.addEventListener('animationend', this.close); - } - - closePopupOnEsc (event) { - if (event.keyCode === 27 && this.props.open) { - this.animateClose(); - } - } - - componentWillReceiveProps (nextProps) { - if (nextProps.open) { - document.body.style.overflow = 'hidden'; - } else { - document.body.style.removeProperty('overflow'); - } - } - - componentDidMount () { - if (this.props.open) { - document.body.style.overflow = 'hidden'; - } - document.addEventListener('keydown', this.closePopupOnEsc); - } - - componentWillUnmount () { - document.body.style.removeProperty('overflow'); - document.removeEventListener('keydown', this.closePopupOnEsc); - } - - renderContent () { - const popupClassName = `popup${this.props.className ? ' ' + this.props.className : ''}`; - const contentBgClassName = ` popup__content_bg_${this.props.bg}`; - const contentPaddingClassName = ` popup__content_padding_${this.props.padding}`; - const contentClassName = `popup__content popup__content_animate_show${contentPaddingClassName}${contentBgClassName}`; - const closeBtnClassName = `popup__close-btn popup__close-btn_bg_${this.props.bg}`; - const closeCrossClassName = `popup__close-cross popup__close-cross_bg_${this.props.bg}`; - - return ( - - ); - } - - render () { - return ( - this.props.open === true ? this.renderContent() : null - ); - } -} diff --git a/src/components/Popup.less b/src/components/Popup.less deleted file mode 100644 index e8c16be..0000000 --- a/src/components/Popup.less +++ /dev/null @@ -1,276 +0,0 @@ -.popup { - box-sizing: border-box; - height: 100%; - left: 0; - position: fixed; - -webkit-text-size-adjust: 100%; - -ms-text-size-adjust: 100%; - top: 0; - width: 100%; - z-index: 9999; - overflow: auto; - line-height: 100vh; - text-align: center; - - *, - *::before, - *::after { - box-sizing: border-box; - } - - &__bg { - background-color: #243238; - bottom: 0; - left: 0; - opacity: .95; - position: fixed; - right: 0; - top: 0; - z-index: 0; - } - - &__content { - animation-duration: .3s; - animation-fill-mode: forwards; - animation-timing-function: cubic-bezier(.86, 0, .07, 1); - border-radius: 3px; - display: inline-block; - position: relative; - z-index: 1; - line-height: 1; - vertical-align: middle; - - &_padding { - &_none { - &.dropdown__content_bg_transparent { - padding: 40px; - } - - &.dropdown__content_bg_fill { - padding: 0; - } - } - - &_medium { - padding: 40px; - } - - &_large { - padding: 80px; - } - } - - &_bg { - &_transparent { - background-color: rgba(0,0,0,0); - color: #fff; - } - - &_fill { - background-color: #fff; - - &.popup__content_padding_none, - &.popup__content_padding_medium { - margin: 40px; - max-width: calc(~"100% - 80px"); - } - - &.popup__content_padding_large { - margin: 80px; - max-width: calc(~"100% - 160px"); - } - } - } - - &_animate_show { - animation-name: showPopupContent; - } - - &_animate_hide { - animation-name: hidePopupContent; - } - - @keyframes showPopupContent { - from { - opacity: 0; - transform: scale(.8); - } - - to { - opacity: 1; - transform: scale(1); - } - } - - @keyframes hidePopupContent { - from { - opacity: 1; - transform: scale(1); - } - - to { - opacity: 0; - transform: scale(.8); - } - } - } - - &__close { - &-btn { - background: rgba(0, 0, 0, 0); - width: 40px; - height: 40px; - cursor: pointer; - position: absolute; - -webkit-text-decoration-skip: objects; - -webkit-text-size-adjust: 100%; - -ms-text-size-adjust: 100%; - z-index: 2; - - &::-moz-focus-inner { - border-style: none; - padding: 0; - } - - &_bg { - &_fill { - right: -20px; - top: -20px; - } - - &_transparent { - left: 100%; - top: 0; - } - } - } - - &-cross { - position: absolute; - border-radius: 50%; - top: 50%; - left: 50%; - transform: translate(-50%, -50%) rotate(45deg); - z-index: 2; - - &::before, - &::after { - content: ""; - position: absolute; - background-color: #fff; - } - - &_bg { - &_fill { - background-color: #b0bec5; - height: 30px; - width: 30px; - - &::before { - width: 16px; - height: 4px; - left: 7px; - top: 13px; - } - - &::after { - width: 4px; - height: 16px; - left: 13px; - top: 7px; - } - - .popup__close-btn:hover &, - .popup__close-btn:focus & { - background-color: #d84315; - } - } - - &_transparent { - background-color: rgba(0,0,0,0); - width: 26px; - height: 26px; - - &::before, - &::after { - left: 50%; - top: 50%; - transform: translate(-50%, -50%); - - .popup__close-btn:hover &, - .popup__close-btn:focus & { - background-color: #d84315; - } - } - - &::before { - width: 100%; - height: 3px; - } - - &::after { - width: 3px; - height: 100%; - } - } - } - } - - - &-text { - background-color: #546e7a; - border-radius: 3px; - color: #fff; - font-size: 13px; - height: 40px; - line-height: 40px; - opacity: 0; - padding: 0 20px; - position: absolute; - transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55); - transition-delay: .2s; - transition-duration: .5s; - transition-property: opacity, top, transform; - z-index: 1; - - &::before { - background-color: #546e7a; - border-top-right-radius: 3px; - content: ""; - height: 14px; - left: 50%; - margin-left: -7px; - position: absolute; - top: -7px; - transform: rotate(-45deg); - width: 14px; - } - - .popup__close-btn_bg_transparent + & { - left: 100%; - top: 10px; - transform: scale(.8) translateX(-62%); - margin-left: 20px; - } - - .popup__close-btn_bg_fill + & { - left: 100%; - top: -5px; - transform: scale(.8) translateX(-62%); - } - - .popup__close-btn:hover + & { - opacity: 1; - transform: scale(1) translateX(-50%); - } - - .popup__close-btn_bg_transparent:hover + & { - top: 50px; - } - - .popup__close-btn_bg_fill:hover + & { - top: 35px; - } - } - } -} diff --git a/src/components/Popup/Popup.jsx b/src/components/Popup/Popup.jsx new file mode 100644 index 0000000..1a1ae3c --- /dev/null +++ b/src/components/Popup/Popup.jsx @@ -0,0 +1,171 @@ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; + +import './Popup.less'; + +export default class Popup extends Component { + static propTypes = { + onRequestHide: PropTypes.func.isRequired, + show: PropTypes.bool, + contentBg: PropTypes.oneOf(['transparent', 'fill']), + contentPadding: PropTypes.oneOf(['none', 'medium', 'large']), + showCloseBtn: PropTypes.bool, + closeBtnTooltip: PropTypes.node, + closeOnClickOnOverlay: PropTypes.bool, + hideOnPressEsc: PropTypes.bool, + children: PropTypes.node, + className: PropTypes.string, + } + + static defaultProps = { + show: false, + contentBg: 'fill', + contentPadding: 'medium', + showCloseBtn: true, + closeOnClickOnOverlay: true, + closeBtnTooltip: null, + hideOnPressEsc: true, + children: null, + className: null, + }; + + constructor(props) { + super(props); + + this.openCloseBtnTooltipTimeout = null; + } + + state = { + renderContainer: this.props.show, + showCloseBtnTooltip: false, + } + + componentWillReceiveProps(nextProps) { + if (nextProps.show && !this.state.renderContainer) { + this.setState(() => ({ + renderContainer: true, + })); + } + } + + componentWillUnmount() { + document.body.classList.remove('tm-quark-popup__document'); + } + + removeContainer = () => { + this.setState(() => ({ + renderContainer: false, + })); + } + + handleAnimationEnd = (event) => { + if (event.target === this.container) { + if (this.props.show) { + document.body.classList.add('tm-quark-popup__document'); + } else { + document.body.classList.remove('tm-quark-popup__document'); + this.removeContainer(); + } + } + } + + handleBlur = (event) => { + if ( + (event.keyCode === 27 && this.props.hideOnPressEsc) + && this.container + && this.content + && (event.target === this.container || event.target === this.content) + && this.props.show + && this.props.onRequestHide + ) { + this.props.onRequestHide(); + } + } + + handleClickOnOverlay = (event) => { + if ( + this.container + && event.target === this.container + && this.props.closeOnClickOnOverlay + && this.props.onRequestHide + ) { + this.props.onRequestHide(); + } + } + + handleCloseBtnHover = () => { + this.openCloseBtnTooltipTimeout = setTimeout(() => { + this.setState(() => ({ + showCloseBtnTooltip: true, + })); + }, 200); + } + + hideCloseTooltip = () => { + clearTimeout(this.openCloseBtnTooltipTimeout); + + this.setState(() => ({ + showCloseBtnTooltip: false, + })); + } + + render() { + const { + show, + onRequestHide, + contentBg, + contentPadding, + showCloseBtn, + children, + className, + hideOnPressEsc, + closeOnClickOnOverlay, + closeBtnTooltip, + ...popupProps + } = this.props; + + const popupStateClassName = `tm-quark-popup_${show ? 'visible' : 'hidden'}`; + + const popupContentBgClassName = `tm-quark-popup__content_bg_${contentBg}`; + const popupContentPaddingClassName = `tm-quark-popup__content_padding_${contentPadding}`; + + return ( + this.state.renderContainer ? ( +
{ this.container = ref; }} + > +
{ this.content = ref; }} + > + {showCloseBtn && ( + + {closeBtnTooltip} + + )} + + {children} +
+
+ ) : ( + null + ) + ); + } +} diff --git a/src/components/Popup/Popup.less b/src/components/Popup/Popup.less new file mode 100644 index 0000000..c6c48a1 --- /dev/null +++ b/src/components/Popup/Popup.less @@ -0,0 +1,192 @@ +.tm-quark-popup { + animation-duration: .3s; + animation-fill-mode: forwards; + animation-timing-function: cubic-bezier(.86, 0, .07, 1); + background-color: rgba(36, 50, 56, .95); + bottom: 0; + box-sizing: border-box; + left: 0; + line-height: 100vh; + overflow: auto; + position: fixed; + right: 0; + text-align: center; + top: 0; + z-index: 9999; + + *, + *::before, + *::after { + box-sizing: inherit; + } + + &__document { + overflow: hidden; + } + + &_visible { + animation-name: TMQuarkShowPopup; + + @keyframes TMQuarkShowPopup { + from { + opacity: 0; + transform: scale(.8); + } + + to { + opacity: 1; + transform: scale(1); + } + } + } + + &_hidden { + animation-name: TMQuarkHidePopup; + + @keyframes TMQuarkHidePopup { + from { + opacity: 1; + transform: scale(1); + } + + to { + opacity: 0; + transform: scale(.8); + } + } + } + + &:focus { + outline: none; + } + + &__content { + animation-duration: .3s; + animation-fill-mode: forwards; + animation-timing-function: cubic-bezier(.86, 0, .07, 1); + border-radius: 3px; + display: inline-block; + position: relative; + line-height: 1; + vertical-align: middle; + z-index: 1; + + &_padding { + &_none { + &.tm-quark-popup__content_bg_transparent { + padding: 40px; + } + + &.tm-quark-popup__content_bg_fill { + padding: 0; + } + } + + &_medium { + padding: 40px; + } + + &_large { + padding: 80px; + } + } + + &_bg { + &_transparent { + background-color: rgba(0, 0, 0, 0); + color: #fff; + margin: 40px; + max-width: calc(~"100% - 80px"); + } + + &_fill { + background-color: #fff; + + &.tm-quark-popup__content_padding_none, + &.tm-quark-popup__content_padding_medium { + margin: 40px; + max-width: calc(~"100% - 80px"); + } + + &.tm-quark-popup__content_padding_large { + margin: 80px; + max-width: calc(~"100% - 160px"); + } + } + } + } + + &__close-btn { + align-items: center; + display: flex; + height: 40px; + justify-content: center; + position: absolute; + width: 40px; + + &::before, + &::after { + background-color: #fff; + content: ""; + width: 3px; + } + + .tm-quark-popup__content_bg_fill & { + background-color: #b0bec5; + background-clip: padding-box; + border: 5px solid rgba(0, 0, 0, 0); + border-radius: 50%; + right: 0; + top: 0; + transform: translateX(50%) translateY(-50%); + + &:hover { + background-color: #d84315; + } + + &::before, + &::after { + height: 15px; + } + + &::before { + transform: rotate(45deg) translateX(50%); + transform-origin: right; + } + + &::after { + transform: rotate(-45deg) translateX(-50%); + transform-origin: left; + } + } + + .tm-quark-popup__content_bg_transparent & { + right: 0; + top: 0; + transform: translateX(100%) translateY(40px); + + &::before, + &::after { + height: 20px; + border-radius: 3px; + } + + &:hover { + &::before, + &::after { + background-color: #d84315; + } + } + + &::before { + transform: rotate(45deg) translateX(50%); + transform-origin: right; + } + + &::after { + transform: rotate(-45deg) translateX(-50%); + transform-origin: left; + } + } + } +} diff --git a/src/components/Popup/index.js b/src/components/Popup/index.js new file mode 100644 index 0000000..dda4064 --- /dev/null +++ b/src/components/Popup/index.js @@ -0,0 +1,2 @@ +export * from './types/'; +export default from './Popup'; diff --git a/src/components/Popup/types/POP1.jsx b/src/components/Popup/types/POP1.jsx new file mode 100644 index 0000000..fff0d8c --- /dev/null +++ b/src/components/Popup/types/POP1.jsx @@ -0,0 +1,12 @@ +import React from 'react'; + +import Popup from '../Popup'; + +const POP1 = props => ( + +); + +export default POP1; diff --git a/src/components/Popup/types/POP2.jsx b/src/components/Popup/types/POP2.jsx new file mode 100644 index 0000000..03db9c8 --- /dev/null +++ b/src/components/Popup/types/POP2.jsx @@ -0,0 +1,12 @@ +import React from 'react'; + +import Popup from '../Popup'; + +const POP2 = props => ( + +); + +export default POP2; diff --git a/src/components/Popup/types/index.js b/src/components/Popup/types/index.js new file mode 100644 index 0000000..dc67499 --- /dev/null +++ b/src/components/Popup/types/index.js @@ -0,0 +1,2 @@ +export POP1 from './POP1'; +export POP2 from './POP2'; diff --git a/src/components/Radio.jsx b/src/components/Radio.jsx deleted file mode 100644 index d66ec20..0000000 --- a/src/components/Radio.jsx +++ /dev/null @@ -1,30 +0,0 @@ -import React from 'react'; - -import './Radio.less'; - -export default function Radio (props) { - const {className, children, ...inputProps} = props; - - const customClassName = className ? ` ${className}` : ''; - - return ( - - ); -} - -Radio.propTypes = { - className: React.PropTypes.string -}; diff --git a/src/components/Radio/Radio.jsx b/src/components/Radio/Radio.jsx new file mode 100644 index 0000000..725ed9d --- /dev/null +++ b/src/components/Radio/Radio.jsx @@ -0,0 +1,39 @@ +import React from 'react'; +import PropTypes from 'prop-types'; + +import './Radio.less'; + +const Radio = ({ + className, + children, + ...inputProps +}) => ( + +); + +Radio.propTypes = { + className: PropTypes.string, + children: PropTypes.node, +}; + +Radio.defaultProps = { + className: '', + children: null, +}; + +export default Radio; diff --git a/src/components/Radio.less b/src/components/Radio/Radio.less similarity index 100% rename from src/components/Radio.less rename to src/components/Radio/Radio.less diff --git a/src/components/Radio/index.js b/src/components/Radio/index.js new file mode 100644 index 0000000..031c9f5 --- /dev/null +++ b/src/components/Radio/index.js @@ -0,0 +1,2 @@ +export * from './types/'; +export default from './Radio'; diff --git a/src/components/Radio/types/R1.jsx b/src/components/Radio/types/R1.jsx new file mode 100644 index 0000000..09cc7f0 --- /dev/null +++ b/src/components/Radio/types/R1.jsx @@ -0,0 +1,9 @@ +import React from 'react'; + +import Radio from '../Radio'; + +const R1 = props => ( + +); + +export default R1; diff --git a/src/components/Radio/types/index.js b/src/components/Radio/types/index.js new file mode 100644 index 0000000..b123f7b --- /dev/null +++ b/src/components/Radio/types/index.js @@ -0,0 +1 @@ +export R1 from './R1'; diff --git a/src/components/Slider.jsx b/src/components/Slider.jsx deleted file mode 100644 index 8e81e15..0000000 --- a/src/components/Slider.jsx +++ /dev/null @@ -1,310 +0,0 @@ -import React, {Component, PropTypes} from 'react'; - -import './Slider.less'; - -export default class Slider extends Component { - static propTypes = { - containerClassName : PropTypes.string, - containerId : PropTypes.string, - containerName : PropTypes.string, - orientation : PropTypes.oneOf(['horizontal', 'vertical']), - onChange : PropTypes.func, - min : PropTypes.number.isRequired, - max : PropTypes.number.isRequired, - labeledValues : PropTypes.array, - labeledValuesStep : PropTypes.number, - labelPattern : PropTypes.string, - showMinValue : PropTypes.bool, - showMaxValue : PropTypes.bool, - showMiddleValue : PropTypes.bool - } - - static defaultProps = { - containerClassName : '', - className : '', - orientation : 'horizontal', - labelPattern : '[]', - showMinValue : true, - showMaxValue : true, - showMiddleValue : true - } - - state = { - currentValuePosition : 100 * ((this.props.value || this.props.defaultValue || this.props.min) - this.props.min) / (this.props.max - this.props.min), - isThumbHovered : false - } - - constructor (props) { - super(props); - - this.setThumbHover = this.setThumbHover.bind(this); - this.resetThumbHover = this.resetThumbHover.bind(this); - - this.handleRangeChange = this.handleRangeChange.bind(this); - - this.handleRangeMouseDown = this.handleRangeMouseDown.bind(this); - this.handleRangeMouseUp = this.handleRangeMouseUp.bind(this); - this.handleRangeMouseMove = this.handleRangeMouseMove.bind(this); - - this.handleRangeTouchStart = this.handleRangeTouchStart.bind(this); - this.handleRangeTouchEnd = this.handleRangeTouchEnd.bind(this); - this.handleRangeTouchMove = this.handleRangeTouchMove.bind(this); - - this.thumbHalfWidth = 15; - this.isMouseFocused = false; - this.isTouchFocused = false; - } - - setThumbHover () { - this.setState({ - isThumbHovered: true - }); - } - - resetThumbHover () { - this.setState({ - isThumbHovered: false - }); - } - - handleRangeMouseDown (event) { - this.isMouseFocused = true; - - document.addEventListener('mousemove', this.handleRangeMouseMove); - document.addEventListener('mouseup', this.handleRangeMouseUp); - - this.handleRangeChange(event); - } - - handleRangeMouseMove (event) { - this.isMouseFocused && this.handleRangeChange(event); - } - - handleRangeMouseUp (event) { - this.isMouseFocused = false; - - document.removeEventListener('mousemove', this.handleRangeMouseMove); - document.removeEventListener('mouseup', this.handleRangeMouseUp); - - this.handleRangeChange(event); - } - - handleRangeTouchStart (event) { - this.isTouchFocused = true; - - document.addEventListener('touchmove', this.handleRangeTouchMove); - document.addEventListener('touchend', this.handleRangeTouchEnd); - - this.handleRangeChange(event); - } - - handleRangeTouchMove (event) { - this.isTouchFocused && this.handleRangeChange(event); - } - - handleRangeTouchEnd (event) { - this.isTouchFocused = false; - - document.removeEventListener('touchmove', this.handleRangeTouchMove); - document.removeEventListener('touchend', this.handleRangeTouchEnd); - - this.handleRangeChange(event); - } - - handleRangeChange (event) { - const rangeValue = event.target.value; - - this.setState({ - currentValuePosition: 100 * (rangeValue - this.props.min) / (this.props.max - this.props.min) - }, () => { - this.hideOverlappingValues(); - this.props.onChange && this.props.onChange(rangeValue); - }); - } - - hideOverlappingValues () { - if (this.container) { - const containerWidth = this.container.offsetWidth; - const containerHeight = this.container.offsetHeight; - const currentValueWidth = this.currentValueContainer.offsetWidth; - const currentValueHeight = this.currentValueContainer.offsetHeight; - - const currentValuePositionInPX = (this.props.orientation === 'horizontal' ? containerWidth : containerHeight) * this.state.currentValuePosition / 100; - - this.intermediateValuesLabels.forEach((label) => { - if (label.container) { - const labelPositionInPX = ((this.props.orientation === 'horizontal' ? containerWidth : containerHeight) * label.position) / 100; - - const labelStartHidePosition = labelPositionInPX - (this.props.orientation === 'horizontal' ? label.container.offsetWidth : label.container.offsetHeight); - const labelEndHidePosition = labelPositionInPX + (this.props.orientation === 'horizontal' ? currentValueWidth : currentValueHeight); - - if (labelStartHidePosition <= currentValuePositionInPX && labelEndHidePosition >= currentValuePositionInPX) { - label.container.classList.add('tm-quark-slider__label_hidden'); - } else { - label.container.classList.remove('tm-quark-slider__label_hidden'); - } - } - }); - } - } - - getLabeledValuesByStep (labeledValuesStep = this.props.max - this.props.min) { - return Array.from({ - length: Math.floor((this.props.max - this.props.min) / labeledValuesStep) + 1 - }).map((value, valueIndex) => { - return this.props.min + (valueIndex * labeledValuesStep); - }); - } - - getDisplayedValues () { - const { - min, - max, - showMiddleValue, - showMinValue, - showMaxValue, - labeledValues, - labeledValuesStep - } = this.props; - - const middleValue = (this.props.max + this.props.min) / 2; - - return [ - ...new Set([ - ...(labeledValues || this.getLabeledValuesByStep(labeledValuesStep)), - min, - max, - middleValue - ]) - ].filter((value) => { - const isMinValue = value === min; - const isMaxValue = value === max; - const isMiddleValue = value === middleValue / 2; - - const isHidden = isMaxValue && !showMaxValue || isMinValue && !showMinValue || isMiddleValue && !showMiddleValue; - - return !isHidden; - }); - } - - componentDidMount () { - this.hideOverlappingValues(); - window.addEventListener('resize', this.hideOverlappingValues); - } - - componentWillReceiveProps (nextProps) { - const nextRangeValue = nextProps.value || (this.input ? this.input.value : this.props.defaultValue) || nextProps.min; - - this.setState({ - currentValuePosition: 100 * (nextRangeValue - nextProps.min) / (nextProps.max - nextProps.min) - }, this.hideOverlappingValues); - } - - componentWillUnmount () { - document.removeEventListener('mousemove', this.handleRangeMouseMove); - document.removeEventListener('mouseup', this.handleRangeMouseUp); - document.removeEventListener('touchmove', this.handleRangeTouchMove); - document.removeEventListener('touchend', this.handleRangeTouchEnd); - - window.removeEventListener('resize', this.hideOverlappingValues); - } - - render () { - const { - containerClassName, - containerId, - containerName, - className, - orientation, - showMinValue, - showMiddleValue, - showMaxValue, - labeledValues, - labeledValuesStep, - labelPattern, - ...sliderProps - } = this.props; - - this.currentValue = this.props.value || (this.input ? this.input.value : this.props.defaultValue || this.props.min); - this.currentValuePosition = 100 * (this.currentValue - this.props.min) / (this.props.max - this.props.min); - this.intermediateValuesLabels = []; - - const currentValueText = labelPattern.replace(/\[\]/g, this.currentValue); - - const displayedValues = this.getDisplayedValues(); - - return ( -
{ this.container = ref; }} - > - - {displayedValues.map((value, valueIndex) => { - const valuePosition = ((value - this.props.min) / (this.props.max - this.props.min)) * 100; - const valueLabelText = labelPattern.replace(/\[\]/g, value); - - return ( - { - this.intermediateValuesLabels.push({ - container : ref, - position : valuePosition, - hidden : false - }); - }} - key = {value} - > - {valueLabelText} - - ); - })} - - { this.currentValueContainer = ref; }} - > - {currentValueText} - - - - - { this.input = ref; }} - /> - - { this.thumb = ref; }} - > - - - -
- ); - } -}; diff --git a/src/components/Slider/Slider.jsx b/src/components/Slider/Slider.jsx new file mode 100644 index 0000000..37646dc --- /dev/null +++ b/src/components/Slider/Slider.jsx @@ -0,0 +1,346 @@ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; + +import './Slider.less'; + +export default class Slider extends Component { + static propTypes = { + containerClassName: PropTypes.string, + containerId: PropTypes.string, + containerName: PropTypes.string, + orientation: PropTypes.oneOf(['horizontal', 'vertical']), + onChange: PropTypes.func, + min: PropTypes.number.isRequired, + max: PropTypes.number.isRequired, + labelColor: PropTypes.string, + labeledValues: PropTypes.arrayOf(PropTypes.number), + labeledValuesStep: PropTypes.number, + labelPattern: PropTypes.string, + showMinValue: PropTypes.bool, + showMaxValue: PropTypes.bool, + showMiddleValue: PropTypes.bool, + value: PropTypes.number, + defaultValue: PropTypes.number, + className: PropTypes.string, + } + + static defaultProps = { + containerId: null, + containerName: null, + containerClassName: '', + className: '', + orientation: 'horizontal', + labelColor: '#1ab744', + labelPattern: '[]', + showMinValue: true, + showMaxValue: true, + showMiddleValue: true, + onChange: () => {}, + labeledValues: [], + labeledValuesStep: null, + value: null, + defaultValue: null, + } + + constructor(props) { + super(props); + + this.thumbHalfWidth = 15; + this.isMouseFocused = false; + this.isTouchFocused = false; + } + + state = { + currentValuePosition: 100 * (( + (this.props.value || this.props.defaultValue || this.props.min) - this.props.min + ) / (this.props.max - this.props.min)), + isThumbHovered: false, + } + + componentDidMount() { + this.hideOverlappingValues(); + window.addEventListener('resize', this.hideOverlappingValues); + } + + componentWillReceiveProps(nextProps) { + const nextRangeValue = ( + nextProps.value + || (this.input ? this.input.value : this.props.defaultValue) + || nextProps.min + ); + + this.setState({ + currentValuePosition: 100 * ( + (nextRangeValue - nextProps.min) / (nextProps.max - nextProps.min) + ), + }, this.hideOverlappingValues); + } + + componentWillUnmount() { + document.removeEventListener('mousemove', this.handleRangeMouseMove); + document.removeEventListener('mouseup', this.handleRangeMouseUp); + document.removeEventListener('touchmove', this.handleRangeTouchMove); + document.removeEventListener('touchend', this.handleRangeTouchEnd); + + window.removeEventListener('resize', this.hideOverlappingValues); + } + + getLabeledValuesByStep = (labeledValuesStep = this.props.max - this.props.min) => Array.from({ + length: Math.floor((this.props.max - this.props.min) / labeledValuesStep) + 1, + }).map((value, valueIndex) => this.props.min + (valueIndex * labeledValuesStep)) + + getDisplayedValues = () => { + const { + min, + max, + showMiddleValue, + showMinValue, + showMaxValue, + labeledValues, + labeledValuesStep, + } = this.props; + + const middleValue = (this.props.max + this.props.min) / 2; + + return [ + ...new Set([ + ...(labeledValues || this.getLabeledValuesByStep(labeledValuesStep)), + min, + max, + middleValue, + ]), + ].filter((value) => { + const isMinValue = value === min; + const isMaxValue = value === max; + const isMiddleValue = value === middleValue / 2; + + const isHidden = ( + (isMaxValue && !showMaxValue) + || (isMinValue && !showMinValue) + || (isMiddleValue && !showMiddleValue) + ); + + return !isHidden; + }); + } + + setThumbHover = () => { + this.setState({ + isThumbHovered: true, + }); + } + + resetThumbHover = () => { + this.setState({ + isThumbHovered: false, + }); + } + + handleRangeMouseDown = (event) => { + this.isMouseFocused = true; + + document.addEventListener('mousemove', this.handleRangeMouseMove); + document.addEventListener('mouseup', this.handleRangeMouseUp); + + this.handleRangeChange(event); + } + + handleRangeMouseMove = (event) => { + if (this.isMouseFocused) { + this.handleRangeChange(event); + } + } + + handleRangeMouseUp = (event) => { + this.isMouseFocused = false; + + document.removeEventListener('mousemove', this.handleRangeMouseMove); + document.removeEventListener('mouseup', this.handleRangeMouseUp); + + this.handleRangeChange(event); + } + + handleRangeTouchStart = (event) => { + this.isTouchFocused = true; + + document.addEventListener('touchmove', this.handleRangeTouchMove); + document.addEventListener('touchend', this.handleRangeTouchEnd); + + this.handleRangeChange(event); + } + + handleRangeTouchMove = (event) => { + if (this.isTouchFocused) { + this.handleRangeChange(event); + } + } + + handleRangeTouchEnd = (event) => { + this.isTouchFocused = false; + + document.removeEventListener('touchmove', this.handleRangeTouchMove); + document.removeEventListener('touchend', this.handleRangeTouchEnd); + + this.handleRangeChange(event); + } + + handleRangeChange = (event) => { + const rangeValue = event.target.value; + + this.setState({ + currentValuePosition: 100 * ( + (rangeValue - this.props.min) / (this.props.max - this.props.min) + ), + }, () => { + this.hideOverlappingValues(); + this.props.onChange(rangeValue); + }); + } + + hideOverlappingValues = () => { + if (this.container) { + const containerWidth = this.container.offsetWidth; + const containerHeight = this.container.offsetHeight; + const currentValueWidth = this.currentValueContainer.offsetWidth; + const currentValueHeight = this.currentValueContainer.offsetHeight; + + const currentValuePositionInPX = ( + (this.props.orientation === 'horizontal' ? containerWidth : containerHeight) * this.state.currentValuePosition + ) / 100; + + this.intermediateValuesLabels.forEach((label) => { + if (label.container) { + const labelPositionInPX = ((this.props.orientation === 'horizontal' ? containerWidth : containerHeight) * label.position) / 100; + + const labelStartHidePosition = labelPositionInPX - (this.props.orientation === 'horizontal' ? label.container.offsetWidth : label.container.offsetHeight); + const labelEndHidePosition = labelPositionInPX + (this.props.orientation === 'horizontal' ? currentValueWidth : currentValueHeight); + + if ( + labelStartHidePosition <= currentValuePositionInPX + && labelEndHidePosition >= currentValuePositionInPX + ) { + label.container.classList.add('tm-quark-slider__label_hidden'); + } else { + label.container.classList.remove('tm-quark-slider__label_hidden'); + } + } + }); + } + } + + render() { + const { + containerClassName, + containerId, + containerName, + className, + orientation, + showMinValue, + showMiddleValue, + showMaxValue, + labelColor, + labeledValues, + labeledValuesStep, + labelPattern, + value, + defaultValue, + min, + max, + ...sliderProps + } = this.props; + + this.currentValue = ( + value || + (this.input ? this.input.value : defaultValue || min) + ); + this.currentValuePosition = ( + 100 * ((this.currentValue - min) / (max - min)) + ); + this.intermediateValuesLabels = []; + + const currentValueText = labelPattern.replace(/\[\]/g, this.currentValue); + + const displayedValues = this.getDisplayedValues(); + + return ( +
{ this.container = ref; }} + > + + {displayedValues.map((displayedValue) => { + const valuePosition = ( + 100 * ((displayedValue - min) / (max - min)) + ); + const valueLabelText = labelPattern.replace(/\[\]/g, displayedValue); + + return ( + { + this.intermediateValuesLabels.push({ + container: ref, + position: valuePosition, + hidden: false, + }); + }} + key={displayedValue} + > + {valueLabelText} + + ); + })} + + { this.currentValueContainer = ref; }} + > + {currentValueText} + + + + + { this.input = ref; }} + /> + + { this.thumb = ref; }} + /> + + + +
+ ); + } +} diff --git a/src/components/Slider.less b/src/components/Slider/Slider.less similarity index 81% rename from src/components/Slider.less rename to src/components/Slider/Slider.less index 4d0a39d..7505a14 100644 --- a/src/components/Slider.less +++ b/src/components/Slider/Slider.less @@ -77,7 +77,7 @@ &_value { &_intermediate { font-size: 16px; - transition: color .3s cubic-bezier(0.86, 0, .07, 1); + transition: color .3s cubic-bezier(.86, 0, .07, 1); &::before { content: ""; @@ -86,13 +86,12 @@ height: 5px; position: absolute; transform: translateX(-50%) translateY(-50%); - transition: background-color .3s cubic-bezier(0.86, 0, .07, 1); + transition: background-color .3s cubic-bezier(.86, 0, .07, 1); width: 5px; } } &_current { - color: #1ab744; font-size: 20px; font-weight: 700; } @@ -218,7 +217,7 @@ } &__thumb { - background: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+Cjxzdmcgd2lkdGg9IjEwcHgiIGhlaWdodD0iMTBweCIgdmlld0JveD0iMCAwIDEwIDEwIiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPgogICAgPCEtLSBHZW5lcmF0b3I6IFNrZXRjaCAzLjguMyAoMjk4MDIpIC0gaHR0cDovL3d3dy5ib2hlbWlhbmNvZGluZy5jb20vc2tldGNoIC0tPgogICAgPHRpdGxlPmxpbmVzPC90aXRsZT4KICAgIDxkZXNjPkNyZWF0ZWQgd2l0aCBTa2V0Y2guPC9kZXNjPgogICAgPGRlZnM+PC9kZWZzPgogICAgPGcgaWQ9IlBhZ2UtMSIgc3Ryb2tlPSJub25lIiBzdHJva2Utd2lkdGg9IjEiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICAgICAgPGcgaWQ9IlNsaWRlcnMiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC01ODkuMDAwMDAwLCAtNDM1LjAwMDAwMCkiIGZpbGw9IiNGRkZGRkYiPgogICAgICAgICAgICA8ZyBpZD0iU0xJREVSMSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoNDAuMDAwMDAwLCAzOTAuMDAwMDAwKSI+CiAgICAgICAgICAgICAgICA8ZyBpZD0iY2xpY2tlZCIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoNTM2LjAwMDAwMCwgMC4wMDAwMDApIj4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMTMsNDUuNTA5NjQ5NSBDMTMsNDUuMjI4MTc3OSAxMy4yMzE5MzM2LDQ1IDEzLjUsNDUgQzEzLjc3NjE0MjQsNDUgMTQsNDUuMjI3NjUyOCAxNCw0NS41MDk2NDk1IEwxNCw1NC40OTAzNTA1IEMxNCw1NC43NzE4MjIxIDEzLjc2ODA2NjQsNTUgMTMuNSw1NSBDMTMuMjIzODU3Niw1NSAxMyw1NC43NzIzNDcyIDEzLDU0LjQ5MDM1MDUgTDEzLDQ1LjUwOTY0OTUgWiBNMTYsNDUuNTA5NjQ5NSBDMTYsNDUuMjI4MTc3OSAxNi4yMzE5MzM2LDQ1IDE2LjUsNDUgQzE2Ljc3NjE0MjQsNDUgMTcsNDUuMjI3NjUyOCAxNyw0NS41MDk2NDk1IEwxNyw1NC40OTAzNTA1IEMxNyw1NC43NzE4MjIxIDE2Ljc2ODA2NjQsNTUgMTYuNSw1NSBDMTYuMjIzODU3Niw1NSAxNiw1NC43NzIzNDcyIDE2LDU0LjQ5MDM1MDUgTDE2LDQ1LjUwOTY0OTUgWiBNMTksNDUuNTA5NjQ5NSBDMTksNDUuMjI4MTc3OSAxOS4yMzE5MzM2LDQ1IDE5LjUsNDUgQzE5Ljc3NjE0MjQsNDUgMjAsNDUuMjI3NjUyOCAyMCw0NS41MDk2NDk1IEwyMCw1NC40OTAzNTA1IEMyMCw1NC43NzE4MjIxIDE5Ljc2ODA2NjQsNTUgMTkuNSw1NSBDMTkuMjIzODU3Niw1NSAxOSw1NC43NzIzNDcyIDE5LDU0LjQ5MDM1MDUgTDE5LDQ1LjUwOTY0OTUgWiBNMjIsNDUuNTA5NjQ5NSBDMjIsNDUuMjI4MTc3OSAyMi4yMzE5MzM2LDQ1IDIyLjUsNDUgQzIyLjc3NjE0MjQsNDUgMjMsNDUuMjI3NjUyOCAyMyw0NS41MDk2NDk1IEwyMyw1NC40OTAzNTA1IEMyMyw1NC43NzE4MjIxIDIyLjc2ODA2NjQsNTUgMjIuNSw1NSBDMjIuMjIzODU3Niw1NSAyMiw1NC43NzIzNDcyIDIyLDU0LjQ5MDM1MDUgTDIyLDQ1LjUwOTY0OTUgWiIgaWQ9ImxpbmVzIj48L3BhdGg+CiAgICAgICAgICAgICAgICA8L2c+CiAgICAgICAgICAgIDwvZz4KICAgICAgICA8L2c+CiAgICA8L2c+Cjwvc3ZnPg==") no-repeat center, linear-gradient(to bottom, #42a5f5 0%, #2196f3 100%); + background: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+Cjxzdmcgd2lkdGg9IjEwcHgiIGhlaWdodD0iMTBweCIgdmlld0JveD0iMCAwIDEwIDEwIiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPgogICAgPCEtLSBHZW5lcmF0b3I6IFNrZXRjaCAzLjguMyAoMjk4MDIpIC0gaHR0cDovL3d3dy5ib2hlbWlhbmNvZGluZy5jb20vc2tldGNoIC0tPgogICAgPHRpdGxlPmxpbmVzPC90aXRsZT4KICAgIDxkZXNjPkNyZWF0ZWQgd2l0aCBTa2V0Y2guPC9kZXNjPgogICAgPGRlZnM+PC9kZWZzPgogICAgPGcgaWQ9IlBhZ2UtMSIgc3Ryb2tlPSJub25lIiBzdHJva2Utd2lkdGg9IjEiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICAgICAgPGcgaWQ9IlNsaWRlcnMiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC01ODkuMDAwMDAwLCAtNDM1LjAwMDAwMCkiIGZpbGw9IiNGRkZGRkYiPgogICAgICAgICAgICA8ZyBpZD0iU0xJREVSMSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoNDAuMDAwMDAwLCAzOTAuMDAwMDAwKSI+CiAgICAgICAgICAgICAgICA8ZyBpZD0iY2xpY2tlZCIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoNTM2LjAwMDAwMCwgMC4wMDAwMDApIj4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMTMsNDUuNTA5NjQ5NSBDMTMsNDUuMjI4MTc3OSAxMy4yMzE5MzM2LDQ1IDEzLjUsNDUgQzEzLjc3NjE0MjQsNDUgMTQsNDUuMjI3NjUyOCAxNCw0NS41MDk2NDk1IEwxNCw1NC40OTAzNTA1IEMxNCw1NC43NzE4MjIxIDEzLjc2ODA2NjQsNTUgMTMuNSw1NSBDMTMuMjIzODU3Niw1NSAxMyw1NC43NzIzNDcyIDEzLDU0LjQ5MDM1MDUgTDEzLDQ1LjUwOTY0OTUgWiBNMTYsNDUuNTA5NjQ5NSBDMTYsNDUuMjI4MTc3OSAxNi4yMzE5MzM2LDQ1IDE2LjUsNDUgQzE2Ljc3NjE0MjQsNDUgMTcsNDUuMjI3NjUyOCAxNyw0NS41MDk2NDk1IEwxNyw1NC40OTAzNTA1IEMxNyw1NC43NzE4MjIxIDE2Ljc2ODA2NjQsNTUgMTYuNSw1NSBDMTYuMjIzODU3Niw1NSAxNiw1NC43NzIzNDcyIDE2LDU0LjQ5MDM1MDUgTDE2LDQ1LjUwOTY0OTUgWiBNMTksNDUuNTA5NjQ5NSBDMTksNDUuMjI4MTc3OSAxOS4yMzE5MzM2LDQ1IDE5LjUsNDUgQzE5Ljc3NjE0MjQsNDUgMjAsNDUuMjI3NjUyOCAyMCw0NS41MDk2NDk1IEwyMCw1NC40OTAzNTA1IEMyMCw1NC43NzE4MjIxIDE5Ljc2ODA2NjQsNTUgMTkuNSw1NSBDMTkuMjIzODU3Niw1NSAxOSw1NC43NzIzNDcyIDE5LDU0LjQ5MDM1MDUgTDE5LDQ1LjUwOTY0OTUgWiBNMjIsNDUuNTA5NjQ5NSBDMjIsNDUuMjI4MTc3OSAyMi4yMzE5MzM2LDQ1IDIyLjUsNDUgQzIyLjc3NjE0MjQsNDUgMjMsNDUuMjI3NjUyOCAyMyw0NS41MDk2NDk1IEwyMyw1NC40OTAzNTA1IEMyMyw1NC43NzE4MjIxIDIyLjc2ODA2NjQsNTUgMjIuNSw1NSBDMjIuMjIzODU3Niw1NSAyMiw1NC43NzIzNDcyIDIyLDU0LjQ5MDM1MDUgTDIyLDQ1LjUwOTY0OTUgWiIgaWQ9ImxpbmVzIj48L3BhdGg+CiAgICAgICAgICAgICAgICA8L2c+CiAgICAgICAgICAgIDwvZz4KICAgICAgICA8L2c+CiAgICA8L2c+Cjwvc3ZnPg==") no-repeat center, linear-gradient(to bottom, #42a5f5 0%, #2196f3 100%); border-radius: 50%; cursor: pointer; height: 30px; @@ -257,7 +256,7 @@ } &__track { - background: linear-gradient(to bottom, #dde3e6 0%, #eceff1 100%); + background: linear-gradient(to bottom, #dde3e6 0%, #eceff1 100%); border-radius: 3px; position: absolute; diff --git a/src/components/Slider/index.js b/src/components/Slider/index.js new file mode 100644 index 0000000..cfdc1c0 --- /dev/null +++ b/src/components/Slider/index.js @@ -0,0 +1,2 @@ +export * from './types/'; +export default from './Slider'; diff --git a/src/components/Slider/types/Slider1.jsx b/src/components/Slider/types/Slider1.jsx new file mode 100644 index 0000000..e305aa3 --- /dev/null +++ b/src/components/Slider/types/Slider1.jsx @@ -0,0 +1,12 @@ +import React from 'react'; + +import Slider from '../Slider'; + +const Slider1 = props => ( + +); + +export default Slider1; diff --git a/src/components/Slider/types/Slider2.jsx b/src/components/Slider/types/Slider2.jsx new file mode 100644 index 0000000..e469b65 --- /dev/null +++ b/src/components/Slider/types/Slider2.jsx @@ -0,0 +1,12 @@ +import React from 'react'; + +import Slider from '../Slider'; + +const Slider2 = props => ( + +); + +export default Slider2; diff --git a/src/components/Slider/types/index.js b/src/components/Slider/types/index.js new file mode 100644 index 0000000..db775fb --- /dev/null +++ b/src/components/Slider/types/index.js @@ -0,0 +1,2 @@ +export Slider1 from './Slider1'; +export Slider2 from './Slider2'; diff --git a/src/components/StarsRating.jsx b/src/components/StarsRating.jsx deleted file mode 100644 index 9255f8a..0000000 --- a/src/components/StarsRating.jsx +++ /dev/null @@ -1,82 +0,0 @@ -import React, {Component} from 'react'; -import './StarsRating.less'; - -export default class StarsRating extends Component { - static propTypes = { - defaultRating : React.PropTypes.number.isRequired, - onChange : React.PropTypes.func, - value : React.PropTypes.number, - disabled : React.PropTypes.bool, - noHovered : React.PropTypes.bool - }; - static defaultProps = { - onChange: () => { - }, - disabled : false, - noHovered : false - }; - state = { - value: this.props.defaultRating - }; - - componentWillReceiveProps (nextProps) { - if (nextProps.defaultRating !== this.props.defaultRating) { - this.setState({ - value: nextProps.defaultRating - }); - } - } - - select (val) { - if (!this.props.disabled) { - this.setState({ - value: val - }, this.props.onChange.bind(this, val)); - } else if (this.props.noHovered) { - this.setState({ - value: this.props.defaultRating - }, this.props.onChange.bind(this, val)); - } - } - - printStarClass (value, i) { - const floor = Math.floor(value); - const free = value - floor; - if (floor < i && i - floor === 1) { - switch (true) { - case free <= 0.2: - return 'stars-rating__icon_empty'; - case free <= 0.7: - return 'stars-rating__icon_half'; - case free <= 0.999: - return ''; - } - } - if (floor < i && i - floor > 1) { - return 'stars-rating__icon_empty'; - } - return ''; - } - - render () { - const starsLength = 5; - return ( -
-
- {Array.from({length: starsLength}).map((value, i) => { - i++; - return ( - - - ); - })} -
-
- ); - }; -} diff --git a/src/components/StarsRating/StarsRating.jsx b/src/components/StarsRating/StarsRating.jsx new file mode 100644 index 0000000..0097920 --- /dev/null +++ b/src/components/StarsRating/StarsRating.jsx @@ -0,0 +1,92 @@ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; +import './StarsRating.less'; + +export default class StarsRating extends Component { + static propTypes = { + defaultRating: PropTypes.number.isRequired, + onChange: PropTypes.func, + disabled: PropTypes.bool, + noHovered: PropTypes.bool, + } + + static defaultProps = { + onChange: () => { + }, + disabled: false, + noHovered: false, + } + + state = { + value: this.props.defaultRating, + } + + componentWillReceiveProps(nextProps) { + if (nextProps.defaultRating !== this.props.defaultRating) { + this.setState({ + value: nextProps.defaultRating, + }); + } + } + + getStarIndex = index => index + + select = (val) => { + if (!this.props.disabled) { + this.setState({ + value: val, + }, this.props.onChange.bind(this, val)); + } else if (this.props.noHovered) { + this.setState({ + value: this.props.defaultRating, + }, this.props.onChange.bind(this, val)); + } + } + + printStarClass = (value, i) => { + const floor = Math.floor(value); + const free = value - floor; + + if (floor < i && i - floor === 1) { + if (free < 1 && free > 0.7) { + return ''; + } + + if (free > 0.2) { + return 'stars-rating__icon_half'; + } + + return 'stars-rating__icon_empty'; + } + + if (floor < i && i - floor > 1) { + return 'stars-rating__icon_empty'; + } + + return ''; + } + + render() { + const starsLength = 5; + + return ( +
+
+ {Array.from({ length: starsLength }).map((value, index) => ( + { + this.select(index); + }} + role="button" + tabIndex="0" + /> + ))} +
+
+ ); + } +} diff --git a/src/components/StarsRating.less b/src/components/StarsRating/StarsRating.less similarity index 61% rename from src/components/StarsRating.less rename to src/components/StarsRating/StarsRating.less index 421068e..d8b54a6 100644 --- a/src/components/StarsRating.less +++ b/src/components/StarsRating/StarsRating.less @@ -11,7 +11,7 @@ width: 20px; padding-right: 5px; vertical-align: text-bottom; - background-image: svg-load("../assets/images/icons/icon-star-fill.svg"); + background-image: svg-load("../../assets/images/icons/icon-star-fill.svg"); background-repeat: no-repeat; border: 10px solid transparent; border-right-width: 0; @@ -23,21 +23,21 @@ border-left-width: 10px; } &_empty { - background-image: svg-load("../assets/images/icons/icon-star-empty.svg"); + background-image: svg-load("../../assets/images/icons/icon-star-empty.svg"); } &_half { - background-image: svg-load("../assets/images/icons/icon-star-half.svg"); + background-image: svg-load("../../assets/images/icons/icon-star-half.svg"); } } &_hovered { &:hover { .stars-rating__icon { - background-image: svg-load("../assets/images/icons/icon-star-fill.svg"); + background-image: svg-load("../../assets/images/icons/icon-star-fill.svg"); cursor: pointer; &:hover { - background-image: svg-load("../assets/images/icons/icon-star-fill.svg"); + background-image: svg-load("../../assets/images/icons/icon-star-fill.svg"); & ~ .stars-rating__icon { - background-image: svg-load("../assets/images/icons/icon-star-empty.svg"); + background-image: svg-load("../../assets/images/icons/icon-star-empty.svg"); } } } diff --git a/src/components/StarsRating/index.js b/src/components/StarsRating/index.js new file mode 100644 index 0000000..67b1369 --- /dev/null +++ b/src/components/StarsRating/index.js @@ -0,0 +1 @@ +export default from './StarsRating'; diff --git a/src/components/Steps.jsx b/src/components/Steps.jsx deleted file mode 100644 index cc94f57..0000000 --- a/src/components/Steps.jsx +++ /dev/null @@ -1,70 +0,0 @@ -import React, {PropTypes} from 'react'; - -import './Steps.less'; - -export default function Steps (props) { - const { - className, - id, - name, - steps, - activeStep, - disableUpcomingSteps, - disablePassedSteps, - onRequestChange - } = props; - - const activeStepContent = steps.filter((step, stepIndex) => { - return stepIndex === activeStep; - })[0].content || null; - - const stepsCustomClassName = `${className ? ` ${className}` : ''}`; - - return ( -
- {props.steps.map((step, stepIndex) => { - const isDisabled = activeStep === stepIndex || step.disabled || (activeStep < stepIndex && disableUpcomingSteps) || (activeStep > stepIndex && disablePassedSteps); - - return ( - - { isDisabled ? null : onRequestChange(stepIndex); }} - > - {step.label || null} - - - ); - })} - -
- {activeStepContent} -
-
- ); -} - -Steps.propTypes = { - steps : PropTypes.arrayOf(PropTypes.object).isRequired, - activeStep : PropTypes.number, - disableUpcomingSteps : PropTypes.bool, - disablePassedSteps : PropTypes.bool, - onRequestChange : PropTypes.func -}; - -Steps.defaultProps = { - activeStep : 0, - disableUpcomingSteps : true, - disablePassedSteps : false, - onRequestChange : () => {} -}; diff --git a/src/components/Steps/Steps.jsx b/src/components/Steps/Steps.jsx new file mode 100644 index 0000000..3438f77 --- /dev/null +++ b/src/components/Steps/Steps.jsx @@ -0,0 +1,88 @@ +import React from 'react'; +import PropTypes from 'prop-types'; + +import './Steps.less'; + +const Steps = ({ + className, + id, + name, + steps, + activeStep, + disableUpcomingSteps, + disablePassedSteps, + onRequestChange, +}) => { + const activeStepContent = steps.find((step, stepIndex) => ( + stepIndex === activeStep || step.id === activeStep + )); + + return ( +
+ {steps.map((step, stepIndex) => { + const isDisabled = ( + activeStep === stepIndex + || step.disabled + || (activeStep < stepIndex && disableUpcomingSteps) + || (activeStep > stepIndex && disablePassedSteps) + ); + + const notActiveStepClassName = activeStep < stepIndex ? 'upcoming' : 'passed'; + const activeStepClassName = activeStep === stepIndex ? 'active' : notActiveStepClassName; + + return ( + + { + if (!isDisabled) { + onRequestChange(stepIndex, step.id || null); + } + }} + tabIndex="0" + > + {step.label || null} + + + ); + })} + +
+ {activeStepContent} +
+
+ ); +}; + +Steps.propTypes = { + steps: PropTypes.arrayOf(PropTypes.object).isRequired, + activeStep: PropTypes.number, + disableUpcomingSteps: PropTypes.bool, + disablePassedSteps: PropTypes.bool, + onRequestChange: PropTypes.func, + className: PropTypes.string, + id: PropTypes.string, + name: PropTypes.string, +}; + +Steps.defaultProps = { + activeStep: 0, + disableUpcomingSteps: true, + disablePassedSteps: false, + onRequestChange: () => {}, + className: '', + id: null, + name: null, +}; + +export default Steps; diff --git a/src/components/Steps.less b/src/components/Steps/Steps.less similarity index 100% rename from src/components/Steps.less rename to src/components/Steps/Steps.less diff --git a/src/components/Steps/index.js b/src/components/Steps/index.js new file mode 100644 index 0000000..361d637 --- /dev/null +++ b/src/components/Steps/index.js @@ -0,0 +1 @@ +export default from './Steps'; diff --git a/src/components/Switcher.jsx b/src/components/Switcher.jsx deleted file mode 100644 index 4db2704..0000000 --- a/src/components/Switcher.jsx +++ /dev/null @@ -1,62 +0,0 @@ -import React from 'react'; - -import './Switcher.less'; - -export default class Switcher extends React.Component { - static propTypes = { - size : React.PropTypes.oneOf(['medium', 'large']).isRequired, - className : React.PropTypes.string, - id : React.PropTypes.string.isRequired, - name : React.PropTypes.string.isRequired - } - - static defaultProps = { - tabIndex: 0 - } - - constructor (props) { - super(props); - - this.handleKeyUp = this.handleKeyUp.bind(this); - } - - handleKeyUp = (event) => { - this.props.onKeyUp ? this.props.onKeyUp() : null; - - if (event.keyCode === 13 && this.input.checked === false) { - this.input.checked = !this.input.checked; - this.label.blur(); - this.props.onChange ? this.props.onChange() : null; - } - } - - render () { - const {size, className, id, name, label, checked, tabIndex, onKeyUp, ...props} = this.props; - const addClassName = className ? ` ${className}` : ''; - - return ( -
- { this.input = ref; }} - /> - -
- ); - } -} diff --git a/src/components/Switcher/Switcher.jsx b/src/components/Switcher/Switcher.jsx new file mode 100644 index 0000000..9fb03e5 --- /dev/null +++ b/src/components/Switcher/Switcher.jsx @@ -0,0 +1,78 @@ +import React from 'react'; +import PropTypes from 'prop-types'; + +import './Switcher.less'; + +export default class Switcher extends React.Component { + static propTypes = { + size: PropTypes.oneOf(['medium', 'large']).isRequired, + className: PropTypes.string, + id: PropTypes.string.isRequired, + name: PropTypes.string.isRequired, + onKeyUp: PropTypes.func, + onChange: PropTypes.func, + checked: PropTypes.bool, + label: PropTypes.node, + tabIndex: PropTypes.number, + } + + static defaultProps = { + tabIndex: 0, + className: '', + onKeyUp: null, + onChange: null, + checked: false, + label: null, + } + + handleKeyUp = (event) => { + this.props.onKeyUp(); + + if (event.keyCode === 13 && this.input.checked === false) { + this.input.checked = !this.input.checked; + this.label.blur(); + this.props.onChange(); + } + } + + render() { + const { + size, + className, + id, + name, + label, + checked, + tabIndex, + onKeyUp, + ...props + } = this.props; + + return ( +
+ { this.input = ref; }} + /> + + +
+ ); + } +} diff --git a/src/components/Switcher.less b/src/components/Switcher/Switcher.less similarity index 92% rename from src/components/Switcher.less rename to src/components/Switcher/Switcher.less index 01d5842..0420f17 100644 --- a/src/components/Switcher.less +++ b/src/components/Switcher/Switcher.less @@ -1,4 +1,4 @@ -.switcher { +.tm-quark-switcher { box-sizing: border-box; display: inline-block; flex-grow: 1; @@ -34,12 +34,12 @@ vertical-align: top; width: 100%; - .switcher_size_medium & { + .tm-quark-switcher_size_medium & { height: 40px; padding: 10px 20px; } - .switcher_size_large & { + .tm-quark-switcher_size_large & { height: 60px; padding: 20px 30px; } @@ -78,11 +78,11 @@ &:active { background-color: #1976d2; - .switcher_size_medium & { + .tm-quark-switcher_size_medium & { padding: 11px 20px 9px; } - .switcher_size_large & { + .tm-quark-switcher_size_large & { padding: 21px 30px 19px; } diff --git a/src/components/Switcher/index.js b/src/components/Switcher/index.js new file mode 100644 index 0000000..97222d0 --- /dev/null +++ b/src/components/Switcher/index.js @@ -0,0 +1,2 @@ +export * from './types/'; +export default from './Switcher'; diff --git a/src/components/Switcher/types/SW1.jsx b/src/components/Switcher/types/SW1.jsx new file mode 100644 index 0000000..cbf4f9d --- /dev/null +++ b/src/components/Switcher/types/SW1.jsx @@ -0,0 +1,12 @@ +import React from 'react'; + +import Switcher from '../Switcher'; + +const SW1 = props => ( + +); + +export default SW1; diff --git a/src/components/Switcher/types/SW2.jsx b/src/components/Switcher/types/SW2.jsx new file mode 100644 index 0000000..65803b4 --- /dev/null +++ b/src/components/Switcher/types/SW2.jsx @@ -0,0 +1,12 @@ +import React from 'react'; + +import Switcher from '../Switcher'; + +const SW2 = props => ( + +); + +export default SW2; diff --git a/src/components/Switcher/types/index.js b/src/components/Switcher/types/index.js new file mode 100644 index 0000000..38c4e4e --- /dev/null +++ b/src/components/Switcher/types/index.js @@ -0,0 +1,2 @@ +export SW1 from './SW1'; +export SW2 from './SW2'; diff --git a/src/components/SwitcherGroup.jsx b/src/components/SwitcherGroup.jsx deleted file mode 100644 index 864a21c..0000000 --- a/src/components/SwitcherGroup.jsx +++ /dev/null @@ -1,13 +0,0 @@ -import React from 'react'; - -import './SwitcherGroup.less'; - -export default class Switcher extends React.Component { - render () { - return ( -
- {this.props.children} -
- ); - } -} diff --git a/src/components/SwitcherGroup/SwitcherGroup.jsx b/src/components/SwitcherGroup/SwitcherGroup.jsx new file mode 100644 index 0000000..484cc93 --- /dev/null +++ b/src/components/SwitcherGroup/SwitcherGroup.jsx @@ -0,0 +1,20 @@ +import React from 'react'; +import PropTypes from 'prop-types'; + +import './SwitcherGroup.less'; + +const SwitcherGroup = ({ children }) => ( +
+ {children} +
+); + +SwitcherGroup.propTypes = { + children: PropTypes.node, +}; + +SwitcherGroup.defaultProps = { + children: null, +}; + +export default SwitcherGroup; diff --git a/src/components/SwitcherGroup.less b/src/components/SwitcherGroup/SwitcherGroup.less similarity index 84% rename from src/components/SwitcherGroup.less rename to src/components/SwitcherGroup/SwitcherGroup.less index 30f9b71..d5d616b 100644 --- a/src/components/SwitcherGroup.less +++ b/src/components/SwitcherGroup/SwitcherGroup.less @@ -1,4 +1,4 @@ -.switcher-group { +.tm-quark-switcher-group { box-sizing: border-box; display: flex; justify-content: space-between; diff --git a/src/components/SwitcherGroup/index.js b/src/components/SwitcherGroup/index.js new file mode 100644 index 0000000..f7a34a7 --- /dev/null +++ b/src/components/SwitcherGroup/index.js @@ -0,0 +1,2 @@ +export * from './types/'; +export default from './SwitcherGroup'; diff --git a/src/components/SwitcherGroup/types/SWG1.jsx b/src/components/SwitcherGroup/types/SWG1.jsx new file mode 100644 index 0000000..2acfaed --- /dev/null +++ b/src/components/SwitcherGroup/types/SWG1.jsx @@ -0,0 +1,9 @@ +import React from 'react'; + +import SwitcherGroup from '../SwitcherGroup'; + +const SWG1 = props => ( + +); + +export default SWG1; diff --git a/src/components/SwitcherGroup/types/index.js b/src/components/SwitcherGroup/types/index.js new file mode 100644 index 0000000..38a471c --- /dev/null +++ b/src/components/SwitcherGroup/types/index.js @@ -0,0 +1 @@ +export SWG1 from './SWG1'; diff --git a/src/components/Tag/Tag.jsx b/src/components/Tag/Tag.jsx new file mode 100644 index 0000000..ef243fc --- /dev/null +++ b/src/components/Tag/Tag.jsx @@ -0,0 +1,96 @@ +import React from 'react'; +import PropTypes from 'prop-types'; + +import './Tag.less'; + +const Tag = ({ + className, + type, + size, + disabled, + showCross, + colorScheme, + children, + ...props +}) => { + if (type === 'button') { + return ( + + ); + } else if (type === 'text') { + return ( + + + {children} + + + {showCross && ( + + )} + + ); + } else if (type === 'link') { + return ( + + + {children} + + + {showCross && ( + + )} + + ); + } + + return null; +}; + +Tag.propTypes = { + className: PropTypes.string, + type: PropTypes.oneOf([ + 'link', + 'button', + 'text', + ]), + size: PropTypes.oneOf([ + 'small', + 'medium', + ]).isRequired, + disabled: PropTypes.bool, + showCross: PropTypes.bool, + colorScheme: PropTypes.oneOf([ + 'blue', + 'red', + ]), + children: PropTypes.node, +}; + +Tag.defaultProps = { + className: '', + disabled: false, + type: 'link', + showCross: false, + colorScheme: 'blue', + children: null, +}; + +export default Tag; diff --git a/src/components/Tag/Tag.less b/src/components/Tag/Tag.less new file mode 100644 index 0000000..f43ef9e --- /dev/null +++ b/src/components/Tag/Tag.less @@ -0,0 +1,136 @@ +.tm-quark-tag { + background-color: transparent; + border: 1px solid; + border-radius: 3px; + box-sizing: border-box; + display: inline-flex; + margin: 0; + padding: 0; + touch-action: manipulation; + text-decoration: none; + vertical-align: top; + + *, + *::before, + *::after { + box-sizing: inherit; + } + + [type="button"]:-moz-focusring { + outline: 0; + } + + &:focus, + &:active { + outline: none; + -moz-outline-style: none; + } + + &_type { + &_link, + &_button { + cursor: pointer; + } + } + + &_size { + &_small { + font-size: 11px; + height: 20px; + line-height: 16px; + padding: 0 9px; + } + + &_medium { + font-size: 14px; + height: 40px; + line-height: 21px; + padding: 0 19px; + } + } + + &_color-scheme { + &_blue { + border-color: #cfd8dc; + color: #90a4ae; + + &:hover { + border-color: #2196f3; + color: #2196f3; + } + + &:active { + background-color: #2196f3; + border-color: #2196f3; + color: #fff; + } + } + + &_red { + border-color: #cfd8dc; + color: #90a4ae; + + &:hover { + border-color: #d84315; + color: #d84315; + } + + &:active { + background-color: #d84315; + border-color: #d84315; + color: #fff; + } + } + } + + &:active { + padding-top: 2px; + } + + &_disabled { + border-color: #dde3e6; + color: #cfd8dc; + cursor: disabled; + pointer-events: none; + } + + &__content { + align-items: center; + display: flex; + flex-flow: row nowrap; + } + + &__cross { + align-items: center; + align-self: center; + display: inline-flex; + height: 100%; + justify-content: center; + margin-left: 10px; + width: 10px; + + .tm-quark-tag:not(:hover, :active, :focus) & { + color: #cfd8dc; + } + + .tm-quark-tag_disabled & { + color: #dde3e6; + } + + &::before, + &::after { + border: 1px solid; + content: ""; + height: 10px; + width: 2px; + } + + &::before { + transform: translateX(50%) rotate(-45deg); + } + + &::after { + transform: translateX(-50%) rotate(45deg); + } + } +} diff --git a/src/components/Tag/index.js b/src/components/Tag/index.js new file mode 100644 index 0000000..f76e106 --- /dev/null +++ b/src/components/Tag/index.js @@ -0,0 +1,2 @@ +export * from './types/'; +export default from './Tag'; diff --git a/src/components/Tag/types/TAG1.jsx b/src/components/Tag/types/TAG1.jsx new file mode 100644 index 0000000..62f8cc9 --- /dev/null +++ b/src/components/Tag/types/TAG1.jsx @@ -0,0 +1,12 @@ +import React from 'react'; + +import Tag from '../Tag'; + +const TAG1 = props => ( + +); + +export default TAG1; diff --git a/src/components/Tag/types/TAG2.jsx b/src/components/Tag/types/TAG2.jsx new file mode 100644 index 0000000..f38d449 --- /dev/null +++ b/src/components/Tag/types/TAG2.jsx @@ -0,0 +1,12 @@ +import React from 'react'; + +import Tag from '../Tag'; + +const TAG2 = props => ( + +); + +export default TAG2; diff --git a/src/components/Tag/types/TAG3.jsx b/src/components/Tag/types/TAG3.jsx new file mode 100644 index 0000000..35a358e --- /dev/null +++ b/src/components/Tag/types/TAG3.jsx @@ -0,0 +1,14 @@ +import React from 'react'; + +import Tag from '../Tag'; + +const TAG3 = props => ( + +); + +export default TAG3; diff --git a/src/components/Tag/types/index.js b/src/components/Tag/types/index.js new file mode 100644 index 0000000..fdf9053 --- /dev/null +++ b/src/components/Tag/types/index.js @@ -0,0 +1,3 @@ +export TAG1 from './TAG1'; +export TAG2 from './TAG2'; +export TAG3 from './TAG3'; diff --git a/src/components/Textarea.jsx b/src/components/Textarea.jsx deleted file mode 100644 index a15c9e7..0000000 --- a/src/components/Textarea.jsx +++ /dev/null @@ -1,164 +0,0 @@ -import React, {Component, PropTypes} from 'react'; -import notifications from './notifications/'; - -import './Textarea.less'; - -export default class Textarea extends Component { - static propTypes = { - containerClassName : PropTypes.string, - containerId : PropTypes.string, - containerName : PropTypes.string, - size : PropTypes.oneOf(['medium', 'large']).isRequired, - showTextareaIcon : PropTypes.bool, - icon : PropTypes.string, - className : PropTypes.string, - focused : PropTypes.bool, - onChange : PropTypes.func, - valid : PropTypes.bool, - invalid : PropTypes.bool, - errorMessage : PropTypes.object - } - - static defaultProps = { - focused: false - } - - state = { - isEmpty : this.props.value ? this.props.value.length === 0 : this.props.defaultValue ? this.props.defaultValue.length === 0 : true, - isDirty : false, - symbolsCount : this.props.maxLength ? this.props.value ? this.props.maxLength - this.props.value.length : this.props.defaultValue ? this.props.maxLength - this.props.defaultValue.length : 0 : 0 - } - - constructor (props) { - super(props); - - this.handleInputChange = this.handleInputChange.bind(this); - } - - focus () { - this.input && this.input.focus(); - } - - blur () { - this.input && this.input.blur(); - } - - handleInputChange (event) { - event.persist(); - - const inputValue = event.target.value; - - const lineBreacks = inputValue.match(/(\r\n|\n|\r)/g); - const lineBreacksCount = lineBreacks ? lineBreacks.length : 0; - - this.setState({ - symbolsCount : inputValue.length + lineBreacksCount, - isEmpty : inputValue.length === 0, - isDirty : true - }, () => { - this.input.style.height = 'auto'; - this.input.style.height = `${this.input.scrollHeight}px`; - this.props.onChange && this.props.onChange(inputValue, event); - }); - } - - componentDidMount () { - this.props.focused && this.focus(); - - this.input.style.height = 'auto'; - this.input.style.height = `${this.input.scrollHeight}px`; - } - - componentWillReceiveProps (nextProps) { - this.setState({ - isEmpty : nextProps.value ? false : this.props.value ? true : this.input.value.length === 0, - symbolsCount : nextProps.value ? nextProps.value.length : this.props.value ? 0 : this.input.value.length - }, () => { - this.input.style.height = 'auto'; - this.input.style.height = `${this.input.scrollHeight}px`; - }); - } - - render () { - const { - containerClassName, - containerId, - containerName, - size, - showTextareaIcon, - icon, - className, - focused, - valid, - invalid, - errorMessage, - showSymbolsCounter, - ...inputProps - } = this.props; - - const containerCustomClassName = containerClassName ? ` ${containerClassName}` : ''; - const containerSizeClassName = ` tm-quark-textarea_size_${size}`; - - const inputSizeClassName = ` tm-quark-textarea__input_size_${size}`; - const inputValidClassName = valid ? ' tm-quark-textarea__input_valid' : ''; - const inputInvalidClassName = invalid ? ' tm-quark-textarea__input_invalid' : ''; - const inputStateClassName = this.state.isEmpty ? ' tm-quark-textarea__input_empty' : ' tm-quark-textarea__input_filled'; - const inputDirtyClassName = this.state.isDirty ? ' tm-quark-textarea__input_dirty' : ''; - const inputCustomClassName = className ? ` ${className}` : ''; - - const fieldIcon = showTextareaIcon && icon ? icon : showTextareaIcon && (showTextareaIcon && (inputProps.type === 'password' || inputProps.type === 'search' || inputProps.type === 'email')) ? inputProps.type : null; - - const inputHasIconClassName = fieldIcon ? ' tm-quark-textarea__input_with-icon' : ''; - - const FieldErrorMessage = errorMessage && errorMessage.type ? notifications[errorMessage.type] : null; - - return ( - - ); - } -} diff --git a/src/components/Textarea/Textarea.jsx b/src/components/Textarea/Textarea.jsx new file mode 100644 index 0000000..7605db0 --- /dev/null +++ b/src/components/Textarea/Textarea.jsx @@ -0,0 +1,219 @@ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; + +import './Textarea.less'; + +export default class Textarea extends Component { + static propTypes = { + containerClassName: PropTypes.string, + containerId: PropTypes.string, + containerName: PropTypes.string, + size: PropTypes.oneOf(['medium', 'large']).isRequired, + showTextareaIcon: PropTypes.bool, + icon: PropTypes.string, + className: PropTypes.string, + focused: PropTypes.bool, + onChange: PropTypes.func, + valid: PropTypes.bool, + invalid: PropTypes.bool, + children: PropTypes.node, + value: PropTypes.string, + defaultValue: PropTypes.string, + maxLength: PropTypes.number, + showSymbolsCounter: PropTypes.bool, + placeholder: PropTypes.node, + disabled: PropTypes.bool, + type: PropTypes.string, + } + + static defaultProps = { + focused: false, + containerClassName: '', + containerId: null, + containerName: null, + disabled: false, + showTextareaIcon: false, + icon: null, + className: '', + onChange: null, + valid: false, + invalid: false, + children: null, + value: null, + defaultValue: null, + maxLength: null, + showSymbolsCounter: false, + placeholder: null, + type: null, + } + + state = { + isEmpty: !(this.props.value || this.props.defaultValue), + isDirty: false, + symbolsCount: this.props.maxLength + ? (this.props.value || this.props.defaultValue || '').length + : 0, + } + + componentDidMount() { + if (this.props.focused) { + this.focus(); + } + + this.input.style.height = 'auto'; + this.input.style.height = `${this.input.scrollHeight}px`; + } + + componentWillReceiveProps(nextProps) { + const { + value: nextValue, + focused: nextFocused, + } = nextProps; + + const { + value: currentValue, + focused: currentFocused, + } = this.props; + + const isEmpty = ( + !nextValue && !!currentValue + ) || ( + !nextValue && !currentValue && this.input.value.length === 0 + ); + + const isNeedToBeFocued = nextFocused && !currentFocused; + + const currentSymbolsCount = currentValue ? 0 : this.input.value.length; + const symbolsCount = nextValue ? nextValue.length : currentSymbolsCount; + + this.setState(() => ({ + isEmpty, + symbolsCount, + }), () => { + this.input.style.height = 'auto'; + this.input.style.height = `${this.input.scrollHeight}px`; + + if (isNeedToBeFocued) { + this.focus(); + } + }); + } + + focus = () => { + if (this.input) { + this.input.focus(); + } + } + + blur = () => { + if (this.input) { + this.input.blur(); + } + } + + handleInputChange = (event) => { + event.persist(); + + const inputValue = event.target.value; + + const lineBreacks = inputValue.match(/(\r\n|\n|\r)/g); + const lineBreacksCount = lineBreacks ? lineBreacks.length : 0; + + this.setState({ + symbolsCount: inputValue.length + lineBreacksCount, + isEmpty: inputValue.length === 0, + isDirty: true, + }, () => { + this.input.style.height = 'auto'; + this.input.style.height = `${this.input.scrollHeight}px`; + this.props.onChange(inputValue, event); + }); + } + + render() { + const { + containerClassName, + containerId, + containerName, + size, + showTextareaIcon, + icon, + className, + focused, + valid, + invalid, + showSymbolsCounter, + value, + placeholder, + defaultValue, + maxLength, + disabled, + type, + children, + ...inputProps + } = this.props; + + const containerCustomClassName = containerClassName ? ` ${containerClassName}` : ''; + const containerSizeClassName = ` tm-quark-textarea_size_${size}`; + + const inputSizeClassName = ` tm-quark-textarea__input_size_${size}`; + const inputValidClassName = valid ? ' tm-quark-textarea__input_valid' : ''; + const inputInvalidClassName = invalid ? ' tm-quark-textarea__input_invalid' : ''; + const inputStateClassName = this.state.isEmpty ? ' tm-quark-textarea__input_empty' : ' tm-quark-textarea__input_filled'; + const inputDirtyClassName = this.state.isDirty ? ' tm-quark-textarea__input_dirty' : ''; + const inputCustomClassName = className ? ` ${className}` : ''; + + const fieldTypeIcon = showTextareaIcon && (type === 'password' || type === 'search' || type === 'email') + ? type + : null; + const fieldIcon = showTextareaIcon && !!icon + ? icon + : fieldTypeIcon; + + const inputHasIconClassName = fieldIcon ? ' tm-quark-textarea__input_with-icon' : ''; + + return ( +