Skip to content

Commit 0ee9b5b

Browse files
authored
feat: focus styles (#130)
* feat: use button tag for select control, add focus styles
1 parent 98a9d4a commit 0ee9b5b

File tree

6 files changed

+40
-22
lines changed

6 files changed

+40
-22
lines changed

package-lock.json

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@
7878
},
7979
"peerDependencies": {
8080
"@doc-tools/transform": "^3.3.2",
81-
"@gravity-ui/page-constructor": "^4.0.0",
82-
"@gravity-ui/uikit": "^5.1.0",
81+
"@gravity-ui/page-constructor": "^4.26.0",
82+
"@gravity-ui/uikit": "^5.12.0",
8383
"react": "^16.0.0 || ^17.0.0 || ^18.0.0"
8484
},
8585
"devDependencies": {
@@ -89,11 +89,11 @@
8989
"@commitlint/config-conventional": "^17.4.3",
9090
"@doc-tools/transform": "^3.3.2",
9191
"@gravity-ui/eslint-config": "^2.0.0",
92-
"@gravity-ui/page-constructor": "^4.20.2",
92+
"@gravity-ui/page-constructor": "^4.26.0",
9393
"@gravity-ui/prettier-config": "^1.0.1",
9494
"@gravity-ui/stylelint-config": "^1.0.0",
9595
"@gravity-ui/tsconfig": "^1.0.0",
96-
"@gravity-ui/uikit": "^5.11.0",
96+
"@gravity-ui/uikit": "^5.12.0",
9797
"@storybook/addon-essentials": "^7.0.27",
9898
"@storybook/cli": "^7.0.27",
9999
"@storybook/preset-scss": "^1.0.3",

src/components/FeedHeader/components/Controls/customRenders.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,16 @@ type RenderSwitcherType = ({
2727
export const renderSwitcher: RenderSwitcherType =
2828
({initial, list, defaultLabel}) =>
2929
// eslint-disable-next-line react/display-name
30-
({onClick, ref}) =>
30+
({onClick, ref, onKeyDown, open}) =>
3131
(
3232
<CustomSwitcher
3333
initial={initial}
3434
defaultLabel={defaultLabel}
3535
list={list}
3636
controlRef={ref}
3737
onClick={onClick}
38+
onKeyDown={onKeyDown}
39+
open={open}
3840
/>
3941
);
4042

src/components/FeedHeader/components/CustomSwitcher/CustomSwitcher.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ $block: '.#{$namespace}feed-custom-switcher';
88

99
&__custom-switcher {
1010
@include text-size(body-2);
11+
@include focusable();
1112
position: relative;
1213

1314
display: flex;
@@ -18,6 +19,10 @@ $block: '.#{$namespace}feed-custom-switcher';
1819
border-radius: var(--g-border-radius-xl);
1920
width: 100%;
2021
line-height: 42px;
22+
text-align: initial;
23+
font-family: inherit;
24+
padding: 0;
25+
margin: 0;
2126

2227
// TODO delete this section after Select can customize the popup list
2328
& + .yc-popup.yc-popup_open {

src/components/FeedHeader/components/CustomSwitcher/CustomSwitcher.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export const CustomSwitcher = ({
2727
list,
2828
onClick,
2929
controlRef,
30+
onKeyDown,
31+
open,
3032
}: CustomSwitcherProps) => {
3133
const itemsNames = useMemo(() => {
3234
const items = list
@@ -38,10 +40,12 @@ export const CustomSwitcher = ({
3840
const hasCounter = itemsNames.length > 1;
3941

4042
return (
41-
<div
43+
<button
4244
className={b('custom-switcher')}
4345
onClick={onClick}
44-
ref={controlRef as LegacyRef<HTMLDivElement>}
46+
ref={controlRef as LegacyRef<HTMLButtonElement>}
47+
onKeyDown={onKeyDown}
48+
aria-expanded={open}
4549
>
4650
<div className={b('custom-switcher-element', {content: true})}>
4751
{itemsNames?.join(', ')}
@@ -54,6 +58,6 @@ export const CustomSwitcher = ({
5458
<div className={b('custom-switcher-element', {arrow: true})}>
5559
<Icon data={DropdownArrow} size={ICON_SIZE} className={b('switcher-arrow')} />
5660
</div>
57-
</div>
61+
</button>
5862
);
5963
};

styles/yfm.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,17 @@
9898

9999
a {
100100
color: var(--g-color-text-link);
101+
border-radius: var(--g-focus-border-radius);
101102

102103
&:hover {
103104
color: var(--g-color-text-link-hover);
104105
}
106+
107+
@include focusable(0, 'box-shadow');
108+
109+
&:focus {
110+
outline: 0;
111+
}
105112
}
106113

107114
.yfm-tab {

0 commit comments

Comments
 (0)