Skip to content

Commit ab1feab

Browse files
authored
Merge branch 'main' into cass-gm-833
2 parents b3d5925 + 96d8054 commit ab1feab

24 files changed

+324
-169
lines changed

packages/gamut-kit/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
### [0.6.466](https://github.com/Codecademy/gamut/compare/@codecademy/[email protected]...@codecademy/[email protected]) (2025-01-31)
7+
8+
**Note:** Version bump only for package @codecademy/gamut-kit
9+
10+
### [0.6.465](https://github.com/Codecademy/gamut/compare/@codecademy/[email protected]...@codecademy/[email protected]) (2025-01-31)
11+
12+
**Note:** Version bump only for package @codecademy/gamut-kit
13+
614
### [0.6.464](https://github.com/Codecademy/gamut/compare/@codecademy/[email protected]...@codecademy/[email protected]) (2025-01-29)
715

816
**Note:** Version bump only for package @codecademy/gamut-kit

packages/gamut-kit/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "@codecademy/gamut-kit",
33
"description": "Styleguide & Component library for Codecademy",
4-
"version": "0.6.464",
4+
"version": "0.6.466",
55
"author": "Codecademy Engineering <[email protected]>",
66
"dependencies": {
7-
"@codecademy/gamut": "57.7.3",
7+
"@codecademy/gamut": "58.0.0",
88
"@codecademy/gamut-icons": "9.37.2",
99
"@codecademy/gamut-illustrations": "0.51.0",
1010
"@codecademy/gamut-patterns": "0.10.2",

packages/gamut/CHANGELOG.md

+16
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [58.0.0](https://github.com/Codecademy/gamut/compare/@codecademy/[email protected]...@codecademy/[email protected]) (2025-01-31)
7+
8+
### ⚠ BREAKING CHANGES
9+
10+
- **Menu:** updates menu variants and usage guidance
11+
12+
### Features
13+
14+
- **Menu:** updates menu variants and usage guidance ([3b3e1f6](https://github.com/Codecademy/gamut/commit/3b3e1f662f457f9200b1377b095455874d3f7123))
15+
16+
### [57.7.4](https://github.com/Codecademy/gamut/compare/@codecademy/[email protected]...@codecademy/[email protected]) (2025-01-31)
17+
18+
### Bug Fixes
19+
20+
- **Tip:** Fixes hover gap and click issues with ToolTips and PreviewTips ([84030ff](https://github.com/Codecademy/gamut/commit/84030ff4b4cd1f676a706e8961a4dd95b242445c))
21+
622
### [57.7.3](https://github.com/Codecademy/gamut/compare/@codecademy/[email protected]...@codecademy/[email protected]) (2025-01-29)
723

824
### Bug Fixes

packages/gamut/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@codecademy/gamut",
33
"description": "Styleguide & Component library for Codecademy",
4-
"version": "57.7.3",
4+
"version": "58.0.0",
55
"author": "Codecademy Engineering <[email protected]>",
66
"dependencies": {
77
"@codecademy/gamut-icons": "9.37.2",

packages/gamut/src/DataList/Controls/FilterControl.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const FilterControl: React.FC<FilterProps> = ({
7474
maxHeight={300}
7575
overflowY="auto"
7676
width="max-content"
77-
variant="action"
77+
variant="popover"
7878
>
7979
{[SELECT_ALL, ...options].map((opt) => {
8080
const { text, value } = formatOption(opt);

packages/gamut/src/Menu/Menu.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const Menu = forwardRef<
88
Omit<ComponentProps<typeof List>, 'root'>
99
>(
1010
(
11-
{ children, variant = 'select', spacing = 'normal', role, ...rest },
11+
{ children, variant = 'popover', spacing = 'normal', role, ...rest },
1212
ref
1313
) => {
1414
const currentContext = useMenu({ variant, role, spacing });

packages/gamut/src/Menu/MenuContext.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import { ListProps } from '../List';
44

55
export interface MenuContextProps {
66
spacing: 'normal' | 'condensed';
7-
variant: 'select' | 'navigation' | 'action';
7+
variant: 'popover' | 'fixed';
88
depth: number;
99
role: ListProps['role'];
1010
}
1111

1212
export const MenuContext = createContext<MenuContextProps>({
1313
spacing: 'normal',
14-
variant: 'select',
14+
variant: 'popover',
1515
depth: 0,
1616
role: undefined,
1717
});

packages/gamut/src/Menu/MenuItem.tsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ const getListItemType = (href: boolean, onClick: boolean) =>
1515
href ? 'link' : onClick ? 'button' : 'item';
1616

1717
const activePropnames = {
18-
navigation: 'active-navlink',
19-
action: 'active',
20-
select: 'selected',
18+
fixed: 'active-navlink',
19+
popover: 'active',
2120
};
2221

2322
const currentItemText = {
@@ -41,7 +40,7 @@ export const MenuItem = forwardRef<
4140
const computed = {
4241
...props,
4342
...rest,
44-
variant: variant === 'select' ? 'select' : 'link',
43+
variant: 'link',
4544
role: role === 'menu' ? 'menuitem' : undefined,
4645
[activeProp]: active,
4746
} as ListItemProps;

packages/gamut/src/Menu/MenuSeparator.tsx

-4
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@ import * as React from 'react';
22

33
import { Box, FlexBox } from '../Box';
44
import { FlexBoxProps } from '../Box/props';
5-
import { useMenuContext } from './MenuContext';
65

76
interface MenuSeperatorProps extends FlexBoxProps {
87
children?: never;
98
}
109

1110
export const MenuSeparator: React.FC<MenuSeperatorProps> = (props) => {
12-
const { variant } = useMenuContext();
13-
if (variant !== 'action') return null;
14-
1511
return (
1612
<FlexBox as="li" role="separator" height={8} fit center {...props}>
1713
<Box fit height="1px" bg="text-disabled" borderRadius="sm" mx={16} />

packages/gamut/src/Menu/__tests__/Menu.test.tsx

+7-14
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ describe('Menu', () => {
3939
screen.getByRole('button');
4040
expect(screen.queryByRole('menuitem')).toBeNull();
4141
});
42-
it('renders menu separators when the variant is action', () => {
42+
it('renders menu separators when variant is popover', () => {
4343
renderView({
44-
variant: 'action',
44+
variant: 'popover',
4545
children: <MenuSeparator />,
4646
});
4747

4848
screen.getByRole('separator');
4949
});
50-
it('renders deep menu separators while the parent variant is action', () => {
50+
it('renders deep menu separators', () => {
5151
renderView({
52-
variant: 'action',
52+
variant: 'popover',
5353
children: (
5454
<Menu>
5555
<MenuSeparator />
@@ -59,20 +59,13 @@ describe('Menu', () => {
5959

6060
screen.getByRole('separator');
6161
});
62-
it('does not render separators when the variant is select + navigation', () => {
62+
it('renders menu separators when variant is fixed', () => {
6363
renderView({
64-
variant: 'select',
64+
variant: 'fixed',
6565
children: <MenuSeparator />,
6666
});
6767

68-
expect(screen.queryByRole('separator')).toBeNull();
69-
70-
renderView({
71-
variant: 'navigation',
72-
children: <MenuSeparator />,
73-
});
74-
75-
expect(screen.queryByRole('separator')).toBeNull();
68+
screen.getByRole('separator');
7669
});
7770
it('renders and icon only when specified', () => {
7871
renderView({

packages/gamut/src/Menu/elements.tsx

+14-3
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ export interface ListProps extends ListStyleProps, StyleStateProps {
3232
/** How offset spacing should be */
3333
spacing?: 'normal' | 'condensed';
3434
/** Menu variants for specific use cases and styles */
35-
variant?: 'select' | 'navigation' | 'action';
35+
variant?: 'popover' | 'fixed';
3636
/** is root menu */
3737
root?: boolean;
3838
/** bordered */
3939
as?: 'ul' | 'ol';
40+
showBorder?: boolean;
4041
}
4142

4243
const StyledList = styled('ul', styledOptions<'ul'>())<ListProps>(
@@ -54,6 +55,8 @@ const StyledList = styled('ul', styledOptions<'ul'>())<ListProps>(
5455
minWidth: 192,
5556
bg: 'background',
5657
p: 0,
58+
},
59+
showBorder: {
5760
border: 1,
5861
borderRadius: 'sm',
5962
},
@@ -65,8 +68,16 @@ const StyledList = styled('ul', styledOptions<'ul'>())<ListProps>(
6568
export const List = forwardRef<
6669
HTMLUListElement,
6770
ComponentProps<typeof StyledList>
68-
>(({ context = true, m = 0, root = true, ...rest }, ref) => (
69-
<StyledList context={context} m={m} root={root} ref={ref} {...rest} />
71+
>(({ context = true, m = 0, root = true, variant, ...rest }, ref) => (
72+
<StyledList
73+
context={context}
74+
m={m}
75+
root={root}
76+
showBorder={variant !== 'fixed'}
77+
ref={ref}
78+
variant={variant}
79+
{...rest}
80+
/>
7081
));
7182

7283
const interactiveVariants = system.variant({

packages/gamut/src/Popover/Popover.tsx

+11-6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useWindowScroll, useWindowSize } from 'react-use';
55
import { FocusTrap } from '../FocusTrap';
66
import {
77
Beak,
8+
BeakBox,
89
PatternContainer,
910
PopoverContainer,
1011
PopoverPortal,
@@ -172,12 +173,16 @@ export const Popover: React.FC<PopoverProps> = ({
172173
widthRestricted={widthRestricted}
173174
>
174175
{beak && (
175-
<Beak
176-
outline={outline ? 'outline' : 'boxShadow'}
177-
beak={`${position}-${beak}${variant === 'secondary' ? '-sml' : ''}`}
178-
data-testid="popover-beak"
179-
size={variant === 'secondary' ? 'sml' : 'lrg'}
180-
/>
176+
<BeakBox variant={position}>
177+
<Beak
178+
beak={`${position}-${beak}${
179+
variant === 'secondary' ? '-sml' : ''
180+
}`}
181+
data-testid="popover-beak"
182+
size={variant === 'secondary' ? 'sml' : 'lrg'}
183+
hasBorder={outline || variant === 'secondary'}
184+
/>
185+
</BeakBox>
181186
)}
182187
{children}
183188
</RaisedDiv>

packages/gamut/src/Popover/elements.tsx

+9-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import { AnimatePresence, motion } from 'framer-motion';
55
import * as React from 'react';
66

77
import { BodyPortal } from '../BodyPortal';
8-
import { Box } from '../Box';
8+
import { Box, FlexBox } from '../Box';
99
import { popoverToolTipBodyAlignments } from '../Tip/shared/styles';
1010
import { WithChildrenProp } from '../utils';
1111
import {
12+
beakBorderStates,
13+
beakBoxVariants,
1214
beakSize,
1315
beakVariants,
1416
outlineVariants,
@@ -39,10 +41,13 @@ export const RaisedDiv = styled.div<
3941

4042
export const Beak = styled(Box)<
4143
StyleProps<typeof popoverStates> &
42-
StyleProps<typeof outlineVariants> &
4344
StyleProps<typeof beakVariants> &
44-
StyleProps<typeof beakSize>
45-
>(beakVariants, beakSize);
45+
StyleProps<typeof beakSize> &
46+
StyleProps<typeof beakBorderStates>
47+
>(beakBorderStates, beakVariants, beakSize);
48+
49+
export const BeakBox =
50+
styled(FlexBox)<StyleProps<typeof beakBoxVariants>>(beakBoxVariants);
4651

4752
export const PatternContainer = styled.div(
4853
variant({

packages/gamut/src/Popover/styles.tsx

+27-3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export const raisedDivVariants = variant({
2828
},
2929
});
3030

31+
const borderStyles = { border: 1 } as const;
3132
export const outlineVariants = variant({
3233
defaultVariant: 'boxShadow',
3334
prop: 'outline',
@@ -36,8 +37,7 @@ export const outlineVariants = variant({
3637
boxShadow: '0 0 16px rgba(0, 0, 0, 0.1), 0 0 24px rgba(0, 0, 0, 0.15)',
3738
},
3839
outline: {
39-
borderColor: 'secondary',
40-
border: 1,
40+
...borderStyles,
4141
boxShadow: 'none',
4242
},
4343
},
@@ -50,6 +50,28 @@ export const widthStates = states({
5050
},
5151
});
5252

53+
export const beakBorderStates = states({
54+
hasBorder: borderStyles,
55+
});
56+
57+
export const beakBoxVariants = variant({
58+
base: {
59+
alignItems: 'flex-end',
60+
height: '15px',
61+
justifyContent: 'center',
62+
left: 0,
63+
position: 'absolute',
64+
width: '100%',
65+
},
66+
variants: {
67+
above: {
68+
bottom: -15,
69+
},
70+
below: {
71+
top: -15,
72+
},
73+
},
74+
});
5375
const beakVariantsArray = [
5476
'below-left',
5577
'below-right',
@@ -72,8 +94,10 @@ const beakVariantStyles = createVariantsFromAlignments(
7294

7395
export const beakVariants = variant({
7496
base: {
75-
position: 'absolute',
7697
transform: 'rotate(45deg)',
98+
background: 'transparent',
99+
zIndex: 1,
100+
position: 'fixed',
77101
},
78102
prop: 'beak',
79103
variants: beakVariantStyles,

packages/gamut/src/Popover/utils.tsx

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import { theme } from '@codecademy/gamut-styles';
33
import { tooltipBackgroundColor } from '../Tip/shared/styles';
44

55
const popoverAbove = {
6-
borderRight: 'inherit',
7-
borderBottom: 'inherit',
6+
borderLeft: 'none',
7+
borderTop: 'none',
88
top: 'calc(100% - 10px)',
99
} as const;
1010

1111
const popoverBelow = {
12-
borderLeft: 'inherit',
13-
borderTop: 'inherit',
12+
borderRight: 'none',
13+
borderBottom: 'none',
1414
top: '-10px',
1515
} as const;
1616

@@ -27,14 +27,14 @@ const beakCenter = {
2727
};
2828

2929
const popoverAboveSml = {
30-
borderRight: 'inherit',
31-
borderBottom: 'inherit',
30+
borderLeft: 'none',
31+
borderTop: 'none',
3232
top: 'calc(100% - 8px)',
3333
} as const;
3434

3535
const popoverBelowSml = {
36-
borderLeft: 'inherit',
37-
borderTop: 'inherit',
36+
borderRight: 'none',
37+
borderBottom: 'none',
3838
top: '-8px',
3939
} as const;
4040

0 commit comments

Comments
 (0)