Skip to content

Commit 179100b

Browse files
authored
Merge branch 'main' into np-gm-1107
2 parents 63e5650 + 8487f66 commit 179100b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1490
-699
lines changed

packages/gamut-icons/CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@
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+
## [9.45.0](https://github.com/Codecademy/gamut/compare/@codecademy/[email protected]...@codecademy/[email protected]) (2025-06-10)
7+
8+
### Features
9+
10+
- **Icon:** added new MiniQuoteIcon ([4509029](https://github.com/Codecademy/gamut/commit/4509029deb86760157e0e1051dbf849670a95b92))
11+
12+
## [9.44.0](https://github.com/Codecademy/gamut/compare/@codecademy/[email protected]...@codecademy/[email protected]) (2025-06-04)
13+
14+
### Features
15+
16+
- **Icon:** added new OnlineClassStudentIcon ([66d8b51](https://github.com/Codecademy/gamut/commit/66d8b51d4d0bd101e6b08a5453ed687dbdec0d0f))
17+
18+
## [9.43.0](https://github.com/Codecademy/gamut/compare/@codecademy/[email protected]...@codecademy/[email protected]) (2025-06-03)
19+
20+
### Features
21+
22+
- **Icons:** add new icons for LX Studio platform ([935f58f](https://github.com/Codecademy/gamut/commit/935f58f6fefbe62b7ef1248b146bd95783873d0b))
23+
624
### [9.42.4](https://github.com/Codecademy/gamut/compare/@codecademy/[email protected]...@codecademy/[email protected]) (2025-05-30)
725

826
**Note:** Version bump only for package @codecademy/gamut-icons

packages/gamut-icons/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@codecademy/gamut-icons",
33
"description": "Icon library for codecademy.com",
4-
"version": "9.42.4",
4+
"version": "9.45.0",
55
"author": "Codecademy <[email protected]>",
66
"dependencies": {
77
"@codecademy/gamut-styles": "17.6.3",
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

packages/gamut-kit/CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,26 @@
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.513](https://github.com/Codecademy/gamut/compare/@codecademy/[email protected]...@codecademy/[email protected]) (2025-06-10)
7+
8+
**Note:** Version bump only for package @codecademy/gamut-kit
9+
10+
### [0.6.512](https://github.com/Codecademy/gamut/compare/@codecademy/[email protected]...@codecademy/[email protected]) (2025-06-10)
11+
12+
**Note:** Version bump only for package @codecademy/gamut-kit
13+
14+
### [0.6.511](https://github.com/Codecademy/gamut/compare/@codecademy/[email protected]...@codecademy/[email protected]) (2025-06-04)
15+
16+
**Note:** Version bump only for package @codecademy/gamut-kit
17+
18+
### [0.6.510](https://github.com/Codecademy/gamut/compare/@codecademy/[email protected]...@codecademy/[email protected]) (2025-06-04)
19+
20+
**Note:** Version bump only for package @codecademy/gamut-kit
21+
22+
### [0.6.509](https://github.com/Codecademy/gamut/compare/@codecademy/[email protected]...@codecademy/[email protected]) (2025-06-03)
23+
24+
**Note:** Version bump only for package @codecademy/gamut-kit
25+
626
### [0.6.508](https://github.com/Codecademy/gamut/compare/@codecademy/[email protected]...@codecademy/[email protected]) (2025-05-30)
727

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

packages/gamut-kit/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "@codecademy/gamut-kit",
33
"description": "Styleguide & Component library for Codecademy",
4-
"version": "0.6.508",
4+
"version": "0.6.513",
55
"author": "Codecademy Engineering <[email protected]>",
66
"dependencies": {
7-
"@codecademy/gamut": "63.1.0",
8-
"@codecademy/gamut-icons": "9.42.4",
7+
"@codecademy/gamut": "64.1.0",
8+
"@codecademy/gamut-icons": "9.45.0",
99
"@codecademy/gamut-illustrations": "0.54.4",
1010
"@codecademy/gamut-patterns": "0.10.10",
1111
"@codecademy/gamut-styles": "17.6.3",

packages/gamut/CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,34 @@
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+
## [64.1.0](https://github.com/Codecademy/gamut/compare/@codecademy/[email protected]...@codecademy/[email protected]) (2025-06-10)
7+
8+
### Features
9+
10+
- left/right tooltips ([caaba79](https://github.com/Codecademy/gamut/commit/caaba79f8d1a0de2f4a456d9c9e1609656a9880a))
11+
12+
### [64.0.3](https://github.com/Codecademy/gamut/compare/@codecademy/[email protected]...@codecademy/[email protected]) (2025-06-10)
13+
14+
**Note:** Version bump only for package @codecademy/gamut
15+
16+
### [64.0.2](https://github.com/Codecademy/gamut/compare/@codecademy/[email protected]...@codecademy/[email protected]) (2025-06-04)
17+
18+
**Note:** Version bump only for package @codecademy/gamut
19+
20+
### [64.0.1](https://github.com/Codecademy/gamut/compare/@codecademy/[email protected]...@codecademy/[email protected]) (2025-06-04)
21+
22+
**Note:** Version bump only for package @codecademy/gamut
23+
24+
## [64.0.0](https://github.com/Codecademy/gamut/compare/@codecademy/[email protected]...@codecademy/[email protected]) (2025-06-03)
25+
26+
### ⚠ BREAKING CHANGES
27+
28+
- **Tabs:** Update Tabs to use react aria tabs
29+
30+
### Features
31+
32+
- **Tabs:** Update Tabs to use react aria tabs ([eb87396](https://github.com/Codecademy/gamut/commit/eb87396b21e5e696359c8fb49b3cd2b01609e14a))
33+
634
## [63.1.0](https://github.com/Codecademy/gamut/compare/@codecademy/[email protected]...@codecademy/[email protected]) (2025-05-30)
735

836
### Features

packages/gamut/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
{
22
"name": "@codecademy/gamut",
33
"description": "Styleguide & Component library for Codecademy",
4-
"version": "63.1.0",
4+
"version": "64.1.0",
55
"author": "Codecademy Engineering <[email protected]>",
66
"dependencies": {
7-
"@codecademy/gamut-icons": "9.42.4",
7+
"@codecademy/gamut-icons": "9.45.0",
88
"@codecademy/gamut-illustrations": "0.54.4",
99
"@codecademy/gamut-patterns": "0.10.10",
1010
"@codecademy/gamut-styles": "17.6.3",
1111
"@codecademy/variance": "0.22.1",
12-
"react-aria-components": "1.8.0",
1312
"@types/marked": "^4.0.8",
1413
"@vidstack/react": "^1.12.12",
1514
"classnames": "^2.2.5",
@@ -19,6 +18,7 @@
1918
"lodash": "^4.17.5",
2019
"marked": "^4.3.0",
2120
"polished": "^4.1.2",
21+
"react-aria-components": "1.8.0",
2222
"react-aria-tabpanel": "^4.4.0",
2323
"react-focus-on": "^3.5.1",
2424
"react-hook-form": "^7.53.1",

packages/gamut/src/Coachmark/index.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@ import { useRef } from 'react';
22
import * as React from 'react';
33

44
import { DelayedRenderWrapper } from '../DelayedRenderWrapper';
5-
import { Popover, PopoverBaseProps, PopoverProps } from '../Popover';
5+
import {
6+
Popover,
7+
PopoverFocusProps,
8+
PopoverProps,
9+
PopoverYPositionType,
10+
} from '../Popover';
611

7-
export type CoachmarkProps = PopoverBaseProps & {
12+
export type CoachmarkProps = PopoverFocusProps & {
813
/**
914
* Applied to the element to which the coachmark points.
1015
*/
@@ -29,7 +34,9 @@ export type CoachmarkProps = PopoverBaseProps & {
2934
/**
3035
* Props to be passed into the popover component.
3136
*/
32-
popoverProps?: Partial<PopoverProps>;
37+
popoverProps?: Partial<
38+
Omit<PopoverProps, 'beak' | 'position'> & PopoverYPositionType
39+
>;
3340
};
3441

3542
export const Coachmark: React.FC<CoachmarkProps> = ({

packages/gamut/src/Popover/Popover.tsx

100644100755
Lines changed: 55 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { useCallback, useEffect, useState } from 'react';
2-
import * as React from 'react';
32
import { useWindowScroll, useWindowSize } from 'react-use';
43

54
import { FocusTrap } from '../FocusTrap';
@@ -11,45 +10,20 @@ import {
1110
PopoverPortal,
1211
RaisedDiv,
1312
} from './elements';
13+
import { getBeakVariant } from './styles/beak';
1414
import { PopoverProps } from './types';
15-
16-
const findScrollingParent = ({
17-
parentElement,
18-
}: HTMLElement): HTMLElement | null => {
19-
if (parentElement) {
20-
const { overflow, overflowY, overflowX } = getComputedStyle(parentElement);
21-
if (
22-
[overflow, overflowY, overflowX].some((val) =>
23-
['scroll', 'auto'].includes(val)
24-
)
25-
) {
26-
return parentElement;
27-
}
28-
return findScrollingParent(parentElement); // parent of this parent is used via prop destructure
29-
}
30-
return null;
31-
};
32-
33-
const findResizingParent = ({
34-
parentElement,
35-
}: HTMLElement): HTMLElement | null => {
36-
if (parentElement) {
37-
const { overflow, overflowY, overflowX } = getComputedStyle(parentElement);
38-
if ([overflow, overflowY, overflowX].some((val) => val === 'clip')) {
39-
return parentElement;
40-
}
41-
return findResizingParent(parentElement); // parent of this parent is used via prop destructure
42-
}
43-
return null;
44-
};
15+
import {
16+
findResizingParent,
17+
findScrollingParent,
18+
getDefaultOffset,
19+
} from './utils';
4520

4621
export const Popover: React.FC<PopoverProps> = ({
4722
animation,
4823
align = 'left',
4924
beak,
5025
children,
5126
className,
52-
horizontalOffset = 0,
5327
isOpen,
5428
onRequestClose,
5529
outline = false,
@@ -60,30 +34,72 @@ export const Popover: React.FC<PopoverProps> = ({
6034
role,
6135
variant,
6236
targetRef,
63-
verticalOffset = variant === 'secondary' ? 15 : 20,
37+
horizontalOffset = getDefaultOffset({
38+
axis: 'horizontal',
39+
position,
40+
variant,
41+
}),
42+
verticalOffset = getDefaultOffset({ axis: 'vertical', position, variant }),
43+
6444
widthRestricted,
6545
}) => {
46+
const [popoverHeight, setPopoverHeight] = useState<number>(0);
47+
const [popoverWidth, setPopoverWidth] = useState<number>(0);
6648
const [targetRect, setTargetRect] = useState<DOMRect>();
6749
const [isInViewport, setIsInViewport] = useState(true);
6850
const { width, height } = useWindowSize();
6951
const { x, y } = useWindowScroll();
7052

53+
const getRaisedDivDimsRef = (popover: HTMLDivElement) => {
54+
if (popover && popoverHeight === 0 && popoverWidth === 0) {
55+
const { height, width } = popover.getBoundingClientRect();
56+
setPopoverHeight(height);
57+
setPopoverWidth(width);
58+
}
59+
};
60+
7161
const getPopoverPosition = useCallback(() => {
7262
if (!targetRect) return {};
7363

64+
const isLRCentered = position === 'center';
65+
7466
const positions = {
7567
above: Math.round(targetRect.top - verticalOffset),
7668
below: Math.round(targetRect.top + targetRect.height + verticalOffset),
69+
center: Math.round(
70+
targetRect.top +
71+
targetRect.height / 2 -
72+
popoverHeight / 2 +
73+
verticalOffset
74+
),
7775
};
7876
const alignments = {
79-
right: Math.round(window.scrollX + targetRect.right + horizontalOffset),
80-
left: Math.round(window.scrollX + targetRect.left - horizontalOffset),
77+
right: isLRCentered
78+
? Math.round(targetRect.right + popoverWidth + horizontalOffset)
79+
: Math.round(window.scrollX + targetRect.right + horizontalOffset),
80+
left: isLRCentered
81+
? Math.round(targetRect.left - popoverWidth - horizontalOffset)
82+
: Math.round(window.scrollX + targetRect.left - horizontalOffset),
83+
center: Math.round(
84+
targetRect.left +
85+
targetRect.width / 2 -
86+
popoverWidth / 2 +
87+
horizontalOffset
88+
),
8189
};
8290
return {
8391
top: positions[position],
8492
left: alignments[align],
8593
};
86-
}, [targetRect, verticalOffset, horizontalOffset, align, position]);
94+
}, [
95+
align,
96+
horizontalOffset,
97+
popoverHeight,
98+
popoverWidth,
99+
position,
100+
targetRect,
101+
verticalOffset,
102+
]);
87103

88104
useEffect(() => {
89105
setTargetRect(targetRef?.current?.getBoundingClientRect());
@@ -149,12 +165,12 @@ export const Popover: React.FC<PopoverProps> = ({
149165
},
150166
[onRequestClose, targetRef]
151167
);
152-
153168
if ((!isOpen || !targetRef) && !animation) return null;
154169
const alignment =
155170
(variant === 'primary' || beak) && beak !== 'center'
156171
? 'aligned'
157172
: 'centered';
173+
158174
const contents = (
159175
<PopoverContainer
160176
align={align}
@@ -169,15 +185,14 @@ export const Popover: React.FC<PopoverProps> = ({
169185
<RaisedDiv
170186
alignment={alignment}
171187
outline={outline ? 'outline' : 'boxShadow'}
188+
ref={getRaisedDivDimsRef}
172189
variant={variant}
173190
widthRestricted={widthRestricted}
174191
>
175192
{beak && (
176193
<BeakBox variant={position}>
177194
<Beak
178-
beak={`${position}-${beak}${
179-
variant === 'secondary' ? '-sml' : ''
180-
}`}
195+
beak={getBeakVariant({ align, position, beak, variant })}
181196
data-testid="popover-beak"
182197
hasBorder={outline || variant === 'secondary'}
183198
size={variant === 'secondary' ? 'sml' : 'lrg'}

packages/gamut/src/Popover/elements.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,26 @@ import { timingValues, variant } from '@codecademy/gamut-styles';
22
import { StyleProps } from '@codecademy/variance';
33
import styled from '@emotion/styled';
44
import { AnimatePresence, motion } from 'framer-motion';
5-
import * as React from 'react';
65

76
import { BodyPortal } from '../BodyPortal';
87
import { Box, FlexBox } from '../Box';
9-
import { popoverToolTipBodyAlignments } from '../Tip/shared/styles';
8+
import { popoverToolTipBodyAlignments } from '../Tip/shared/styles/styles';
109
import { WithChildrenProp } from '../utils';
10+
import {
11+
popoverStates,
12+
raisedDivVariants,
13+
transformValues,
14+
} from './styles/base';
15+
import { patternContainerBaseStyles } from './styles/pattern';
1116
import {
1217
beakBorderStates,
1318
beakBoxVariants,
1419
beakSize,
1520
beakVariants,
1621
outlineVariants,
17-
patternContainerBaseStyles,
1822
patternVariantStyles,
19-
popoverStates,
20-
raisedDivVariants,
21-
transformValues,
2223
widthStates,
23-
} from './styles';
24+
} from './styles/variants';
2425
import { PopoverProps } from './types';
2526

2627
export type PopoverVariants = StyleProps<typeof raisedDivVariants> & {

0 commit comments

Comments
 (0)