Skip to content

Commit b2110ab

Browse files
authored
Polish v6 (codesandbox#3509)
* default type of button should be button * change color of theme without opacity * add live color to avatar * collapsible: hide children if not open * make collapsible accessible
1 parent f2c7f93 commit b2110ab

File tree

5 files changed

+20
-6
lines changed

5 files changed

+20
-6
lines changed

packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Live/LiveNow.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,10 @@ const User = ({ user, liveRole }) => {
217217
}}
218218
>
219219
<Stack gap={2} align="center">
220-
<Avatar user={user} />
220+
<Avatar
221+
user={user}
222+
css={{ img: { borderColor: `rgb(${user.color.join(',')})` } }}
223+
/>
221224
<span>
222225
<Text size={2} block>
223226
{user.username}

packages/common/src/themes/codesandbox.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"editorHoverWidget.background": "#1C2022",
1919
"input.background": "#111518",
2020
"input.foreground": "#C0C0C0",
21-
"list.hoverBackground": "#37414050",
21+
"list.hoverBackground": "#222a2b",
2222
"list.focusBackground": "#24282A",
2323
"menu.selectionBackground": "#24282A",
2424
"scrollbarSlider.activeBackground": "#374140",

packages/components/src/components/Avatar/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ export const Pro = styled(Text).attrs({ size: 1, weight: 'bold' })(
4343
})
4444
);
4545

46-
export const Avatar = ({ user }: IAvatarProps) =>
46+
export const Avatar = ({ user, ...props }: IAvatarProps) =>
4747
user && (
48-
<Element as="span" style={{ position: 'relative' }}>
48+
<Element as="span" style={{ position: 'relative' }} {...props}>
4949
<AvatarImage src={user.avatarUrl} alt={user.username} />
5050
{user.subscriptionSince ? <Pro>Pro</Pro> : null}
5151
</Element>

packages/components/src/components/Button/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export const Button = styled(Element).attrs({ as: 'button' })<{
7575
variant?: 'primary' | 'secondary' | 'link' | 'danger';
7676
disabled?: boolean;
7777
onClick?: any;
78-
}>(({ type = 'button', variant = 'primary', ...props }) =>
78+
}>(({ variant = 'primary', ...props }) =>
7979
css(
8080
deepmerge(
8181
// @ts-ignore deepmerge allows functions as values
@@ -115,3 +115,7 @@ export const Button = styled(Element).attrs({ as: 'button' })<{
115115
)
116116
)
117117
);
118+
119+
Button.defaultProps = {
120+
type: 'button',
121+
};

packages/components/src/components/Collapsible/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import styled from 'styled-components';
33
import css from '@styled-system/css';
4+
import VisuallyHidden from '@reach/visually-hidden';
45
import { Element } from '../Element';
56
import { Text } from '../Text';
67
import { SidebarRow } from '../SidebarRow';
@@ -22,6 +23,9 @@ export const Header = styled(SidebarRow).attrs({ gap: 2 })(
2223
':hover': {
2324
backgroundColor: 'sideBar.hoverBackground',
2425
},
26+
':focus-within': {
27+
backgroundColor: 'sideBar.hoverBackground',
28+
},
2529
})
2630
);
2731

@@ -87,9 +91,12 @@ export const Collapsible: React.FC<ICollapsibleProps> = ({
8791
<Header onClick={toggle}>
8892
<ToggleIcon open={open} />
8993
<Text weight="medium">{title}</Text>
94+
<VisuallyHidden>
95+
<input type="checkbox" checked={open} />
96+
</VisuallyHidden>
9097
</Header>
9198

92-
<Body open={open}>{children}</Body>
99+
<Body open={open}>{open ? children : null}</Body>
93100
</Section>
94101
);
95102
};

0 commit comments

Comments
 (0)