Skip to content

Commit eeaa154

Browse files
authored
Merge branch 'main' into jh-md-scss
2 parents bda1abe + 595f173 commit eeaa154

Some content is hidden

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

46 files changed

+1304
-694
lines changed

packages/gamut-icons/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
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/gamut-icons@9.44.0...@codecademy/gamut-icons@9.45.0) (2025-06-10)
7+
8+
### Features
9+
10+
- **Icon:** added new MiniQuoteIcon ([4509029](https://github.com/Codecademy/gamut/commit/4509029deb86760157e0e1051dbf849670a95b92))
11+
612
## [9.44.0](https://github.com/Codecademy/gamut/compare/@codecademy/gamut-icons@9.43.0...@codecademy/gamut-icons@9.44.0) (2025-06-04)
713

814
### Features

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.44.0",
4+
"version": "9.45.0",
55
"author": "Codecademy <dev@codecademy.com>",
66
"dependencies": {
77
"@codecademy/gamut-styles": "17.6.3",
Lines changed: 1 addition & 0 deletions
Loading

packages/gamut-kit/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
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.514](https://github.com/Codecademy/gamut/compare/@codecademy/gamut-kit@0.6.513...@codecademy/gamut-kit@0.6.514) (2025-06-10)
7+
8+
**Note:** Version bump only for package @codecademy/gamut-kit
9+
10+
### [0.6.513](https://github.com/Codecademy/gamut/compare/@codecademy/gamut-kit@0.6.512...@codecademy/gamut-kit@0.6.513) (2025-06-10)
11+
12+
**Note:** Version bump only for package @codecademy/gamut-kit
13+
14+
### [0.6.512](https://github.com/Codecademy/gamut/compare/@codecademy/gamut-kit@0.6.511...@codecademy/gamut-kit@0.6.512) (2025-06-10)
15+
16+
**Note:** Version bump only for package @codecademy/gamut-kit
17+
618
### [0.6.511](https://github.com/Codecademy/gamut/compare/@codecademy/gamut-kit@0.6.510...@codecademy/gamut-kit@0.6.511) (2025-06-04)
719

820
**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.511",
4+
"version": "0.6.514",
55
"author": "Codecademy Engineering <dev@codecademy.com>",
66
"dependencies": {
7-
"@codecademy/gamut": "64.0.2",
8-
"@codecademy/gamut-icons": "9.44.0",
7+
"@codecademy/gamut": "64.1.1",
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: 16 additions & 0 deletions
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+
### [64.1.1](https://github.com/Codecademy/gamut/compare/@codecademy/gamut@64.1.0...@codecademy/gamut@64.1.1) (2025-06-10)
7+
8+
### Bug Fixes
9+
10+
- **ConnectedFormGroup:** Have screen reader read form input error ([5d86b54](https://github.com/Codecademy/gamut/commit/5d86b543ed0434d707feab7aad9df53d54a729f7))
11+
12+
## [64.1.0](https://github.com/Codecademy/gamut/compare/@codecademy/gamut@64.0.3...@codecademy/gamut@64.1.0) (2025-06-10)
13+
14+
### Features
15+
16+
- left/right tooltips ([caaba79](https://github.com/Codecademy/gamut/commit/caaba79f8d1a0de2f4a456d9c9e1609656a9880a))
17+
18+
### [64.0.3](https://github.com/Codecademy/gamut/compare/@codecademy/gamut@64.0.2...@codecademy/gamut@64.0.3) (2025-06-10)
19+
20+
**Note:** Version bump only for package @codecademy/gamut
21+
622
### [64.0.2](https://github.com/Codecademy/gamut/compare/@codecademy/gamut@64.0.1...@codecademy/gamut@64.0.2) (2025-06-04)
723

824
**Note:** Version bump only for package @codecademy/gamut

packages/gamut/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "@codecademy/gamut",
33
"description": "Styleguide & Component library for Codecademy",
4-
"version": "64.0.2",
4+
"version": "64.1.1",
55
"author": "Codecademy Engineering <dev@codecademy.com>",
66
"dependencies": {
7-
"@codecademy/gamut-icons": "9.44.0",
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",

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/ConnectedForm/ConnectedFormGroup.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,24 @@ export function ConnectedFormGroup<T extends ConnectedField>({
8989
);
9090

9191
const textError = customError || getErrorMessage(error);
92+
const showError = !!(textError && !hideLabel);
93+
const errorId = showError ? `${id || name}_error` : undefined;
9294

9395
return (
9496
<FormGroup spacing={hideLabel ? 'tight' : spacing}>
9597
{hideLabel ? <HiddenText>{renderedLabel}</HiddenText> : renderedLabel}
96-
<Component {...(rest as any)} disabled={disabled} name={name} />
98+
<Component
99+
{...(rest as any)}
100+
aria-describedby={errorId}
101+
aria-invalid={showError}
102+
disabled={disabled}
103+
name={name}
104+
/>
97105
{children}
98-
{(error || customError) && !hideLabel && (
106+
{showError && (
99107
<FormError
100108
aria-live={isFirstError ? 'assertive' : 'off'}
109+
id={errorId}
101110
role={isFirstError ? 'alert' : 'status'}
102111
variant={errorType}
103112
>

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'}

0 commit comments

Comments
 (0)