-
Notifications
You must be signed in to change notification settings - Fork 2
[FRNT-330] Rewrite Toggle, change name to Switch #75
Conversation
580c8eb
to
718fe7a
Compare
src/ui/molecules/switch/index.tsx
Outdated
border-color: var(--woly-border-focus, var(--woly-background, #000000)); | ||
} | ||
|
||
input:checked + span[data-checkbox] > span:before { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
можно просто написать input:checked + span[data-checkbox] > span {
.....
&:before {....}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а в чем будет разница?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
лишняя строка уйдет, зачем дублировать + так более прослеживается код, как мне кажется
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ага поняла про чо ты)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
input:checked + span[data-checkbox] > span:before { | |
input:checked + [data-checkbox] > span:before { |
мне кажется лучше убрать все эти span'ы
Второй селектор span:before
вообще непонятно что выбирает. Какой span? Что он делает?
тут поможет вменяемый data-атрибут
718fe7a
to
bc2d30a
Compare
@@ -0,0 +1,188 @@ | |||
import * as React from 'react'; | |||
import styled, { StyledComponent } from 'styled-components'; | |||
import { Variant } from 'lib/types'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
я добавила экспорт Variant в index, чтобы можно одной строкой все экспортить
}) => { | ||
const tabIndex = disabled ? -1 : 0; | ||
|
||
const onKeyDown = React.useCallback( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
многим компонентам будет нужен этот handler, поэтому мб этот handler просто вынести и сюда импортить, чтобы не дублировать код в разных файлах?
src/lib/box-styles.tsx
Outdated
@@ -7,6 +7,8 @@ export const Global = styled.div` | |||
--woly-line-height: 24px; | |||
|
|||
[data-variant='primary'] { | |||
--woly-border-width: 1.5px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это же не имеет отношения к варианту, это просто настройка.
src/ui/molecules/switch/index.tsx
Outdated
--switcher-margin: calc( | ||
var(--woly-switcher-height, 30px) / 2 - | ||
var(--woly-switcher-tumbler-height, 24px) / 2 | ||
); | ||
--switcher-toggle-margin: calc( | ||
var(--woly-switcher-height, 30px) / 2 - | ||
var(--woly-switcher-tumbler-height, 24px) / 2 - 1.5px | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я бы предложил сразу называть все локальные --local
.
А вообще тут проблема, где определены все эти переменные switcher-height
, switcher-tumbpler-height
?
src/ui/molecules/switch/index.tsx
Outdated
width: var(--woly-switcher-width, 57px); | ||
height: var(--woly-switcher-height, 30px); | ||
|
||
background-color: var(--woly-canvas, #c0c0c0); | ||
border-color: var(--woly-canvas, #c0c0c0); | ||
border-style: solid; | ||
border-radius: var(--woly-rounding, 18px); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не стоит использовать default-значения в var(), лучше мы заранее узнаем, что где-то нет правильной переменной, нежели компонент будет скрывать это до последнего
src/ui/molecules/switch/index.tsx
Outdated
&:hover { | ||
span[data-checkbox] > span, | ||
input:checked + span[data-checkbox] > span { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Чет меня пугают такие селекторы, зачем так сложно?
src/ui/molecules/switch/index.tsx
Outdated
border-color: var(--woly-border-focus, var(--woly-background, #000000)); | ||
} | ||
|
||
input:checked + span[data-checkbox] > span:before { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
input:checked + span[data-checkbox] > span:before { | |
input:checked + [data-checkbox] > span:before { |
мне кажется лучше убрать все эти span'ы
Второй селектор span:before
вообще непонятно что выбирает. Какой span? Что он делает?
тут поможет вменяемый data-атрибут
src/ui/molecules/switch/index.tsx
Outdated
} | ||
|
||
label > *:not(:first-child) { | ||
margin-left: var(--woly-gap); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А где определение свойства --woly-gap
?
src/ui/molecules/switch/index.tsx
Outdated
} | ||
} | ||
|
||
&:focus > label > span[data-checkbox] > span { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А реально имеет смысл такая вложенность?
нельзя проще?
&:focus [data-checkbox] span {
Или вообще сразу дать имя этому span'у и указать на него
src/ui/molecules/switch/index.tsx
Outdated
|
||
input:checked + span[data-checkbox] > span { | ||
background-color: var(--woly-background, #b0a3f4); | ||
border-color: var(--woly-border-focus, var(--woly-background, #000000)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а такая ситуация может быть разве, что цвета в переменной не будет?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вообще, нет.
Поэтому любые дефолты по хорошему нужно выпилить
src/ui/molecules/switch/index.tsx
Outdated
import { keyboardEventHandle } from 'lib'; | ||
|
||
/** | ||
* --woly-switcher-width |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
это можно уже удалять наверно
bc2d30a
to
da62018
Compare
da62018
to
059fb78
Compare
059fb78
to
3ee7f6d
Compare
Rewrite Toggle, change name to Switch.
Fix lib/keyboard-events to reuse in different components.
Update missed imports in ui.
https://liberty-base.atlassian.net/browse/FRNT-330