Skip to content

Commit a44090d

Browse files
committed
update dropdown menu styles
1 parent 31d099d commit a44090d

2 files changed

Lines changed: 43 additions & 9 deletions

File tree

src/components/DropdownMenu.stories.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,36 @@ const Menus = (variant: 'light' | 'primary' | 'secondary') => {
3434
Export grades to .csv
3535
</DropdownMenuItem>
3636
</DropdownMenu>
37+
38+
<br/>
39+
40+
<DropdownMenu id='links-menu' text='Resources' variant={variant}>
41+
<DropdownMenuItem href='https://openstax.org' target='_blank'>
42+
Browse subjects
43+
</DropdownMenuItem>
44+
<DropdownMenuItem href='https://openstax.org/subjects' target='_blank'>
45+
View all textbooks
46+
</DropdownMenuItem>
47+
<DropdownMenuItem href='https://openstax.org/about' target='_blank'>
48+
About OpenStax
49+
</DropdownMenuItem>
50+
</DropdownMenu>
51+
52+
<br/>
53+
54+
<div style={{ width: '50rem', maxWidth: '100%' }}>
55+
<DropdownMenu id='links-menu' text='Wide Menu' width="100%" variant={variant}>
56+
<DropdownMenuItem href='https://openstax.org' target='_blank'>
57+
Browse subjects
58+
</DropdownMenuItem>
59+
<DropdownMenuItem href='https://openstax.org/subjects' target='_blank'>
60+
View all textbooks
61+
</DropdownMenuItem>
62+
<DropdownMenuItem href='https://openstax.org/about' target='_blank'>
63+
About OpenStax
64+
</DropdownMenuItem>
65+
</DropdownMenu>
66+
</div>
3767
</>;
3868
};
3969

src/components/DropdownMenu.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ const StyledButton = styled(Button)<{ variant: ButtonVariant; width?: string }>`
1414
flex-direction: row;
1515
font-size: 1.6rem;
1616
position: relative;
17-
justify-content: center;
17+
justify-content: space-between;
1818
line-height: 2rem;
1919
min-height: 2.5rem;
20-
padding: 0 1.5rem 0 0.5rem;
20+
padding: 1rem 2.5rem 1rem 1rem;
2121
text-align: left;
2222
text-decoration: none;
2323
transition: all 0.2s ease-in-out;
2424
user-select: none;
25-
${(props) => props.width ? `width: ${props.width}` : null}
25+
${(props) => props.width ? `width: ${props.width};` : null}
2626
-moz-osx-font-smoothing: grayscale;
2727
-webkit-font-smoothing: antialiased;
2828
@@ -40,34 +40,37 @@ const StyledButton = styled(Button)<{ variant: ButtonVariant; width?: string }>`
4040
content: ' ';
4141
display: block;
4242
position: absolute;
43-
height: 0.5rem;
43+
height: 0.6rem;
4444
margin-top: -0.25rem;
45-
right: 0.5rem;
45+
right: 1rem;
4646
transform: rotate(135deg);
47-
width: 0.5rem;
47+
width: 0.6rem;
4848
}
4949
`;
5050

5151
const StyledMenu = styled(Menu)`
5252
margin-top: -0.6rem;
5353
background-color: ${palette.white};
5454
border: 0.1rem solid ${palette.pale};
55-
padding: 0.3rem 0;
55+
padding: 0;
5656
cursor: pointer;
5757
color: ${palette.black};
5858
5959
[role="menuitem"] {
60+
display: block;
61+
color: inherit;
62+
text-decoration: none;
6063
font-size: 1.6rem;
6164
min-height: 2.5rem;
6265
line-height: 2rem;
63-
padding: 0 0.5rem;
66+
padding: 1rem 0.5rem;
6467
cursor: pointer;
6568
transition: all 0.2s ease-in-out;
6669
-moz-osx-font-smoothing: grayscale;
6770
-webkit-font-smoothing: antialiased;
6871
6972
&:hover {
70-
background-color: ${palette.pale};
73+
background-color: ${palette.neutralLighter};
7174
}
7275
}
7376
`;
@@ -82,6 +85,7 @@ interface DropdownMenuButtonProps<T> extends MenuProps<T>, Omit<MenuTriggerProps
8285
export const DropdownMenu = <T extends object>(
8386
{ text, children, variant, width, disabled, ...props }: DropdownMenuButtonProps<T>
8487
) => {
88+
console.log('width', width);
8589
return (
8690
<MenuTrigger {...props}>
8791
<StyledButton variant={variant} width={width} isDisabled={disabled}>{text}</StyledButton>

0 commit comments

Comments
 (0)