Skip to content

Commit a1d8fc1

Browse files
Merge branch 'reservoir-v4' into DSD-2084/table-fontsize-attribute
2 parents 7f23f81 + 3b68717 commit a1d8fc1

File tree

248 files changed

+2217
-1879
lines changed

Some content is hidden

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

248 files changed

+2217
-1879
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Currently, this repo is in Prerelease. When it is released, this project will ad
1212

1313
- Adds the `useResponsiveSpacing` hook.
1414
- Adds docs for `Responsive Grid` Style Guide.
15+
- Consolidates message variants, sizes, highlight colors, and background colors arrays into shared constants
1516

1617
### Updates
1718

@@ -24,6 +25,8 @@ Currently, this repo is in Prerelease. When it is released, this project will ad
2425
- Removes props with HTML equivalents and instructs devs to use the native attributes
2526
- Updates the grid layout of the content for the `Hero` `"primary"` variant.
2627
- Changes the names of theme objects that conflict with Chakra's base names from `Custom` to `Reservoir` for consistency. This impacts theme objects for `Breadcrumbs`, `Button`, `Select`, `Slider`, and `Table`.
28+
- Replaces positional function args with object references in utility functions/components when there are 3 or more arguments.
29+
- Updates `Table`'s `tableTextSize` prop to accept `caption`.
2730

2831
### Removals
2932

@@ -43,6 +46,9 @@ Currently, this repo is in Prerelease. When it is released, this project will ad
4346
- Removes `role="search"` from `Searchbar` wrapper.
4447
- Removes use of `useNYPLBreakpoints` hook in `FilterBarInline` and `MultiSelectGroup`.
4548
- Removes `isDarkMode` function from `Slider` and `Accordion`.
49+
- Removes `useNYPLBreakpoints` from final component, `SearchBar`, and removes `mediaMatchMock` from test setup since it is no longer necessary.
50+
- Removes explicit `className` and `children` props in favor of expanded prop type definitions in all components.
51+
- Removes the use of the `window`'s `scrollIntoView` dependency in the `Tabs` component.
4652
- Removes the `tableTextSize` prop from the `Table` component in favor of using the native `fontSize` CSS prop.
4753

4854
## Prerelease

package-lock.json

Lines changed: 376 additions & 429 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/__tests__/setup.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,18 @@ import "@testing-library/jest-dom/extend-expect";
44
// expect(...).toHaveNoViolations();
55
import "jest-axe/extend-expect";
66

7-
import MatchMedia from "./mediaMatchMock";
8-
97
jest.setTimeout(35000);
108

119
// We expect an error to be thrown and we do catch, but it still gets
1210
// logged and we don't want to see expected errors while we test.
1311
jest.spyOn(global.console, "error").mockImplementation(() => jest.fn());
1412
jest.spyOn(global.console, "warn").mockImplementation(() => jest.fn());
1513

16-
// Mock match media and resize observer
14+
// Mock resize observer
1715
class ResizeObserver {
1816
observe() {}
1917
unobserve() {}
2018
disconnect() {}
2119
}
2220

2321
window.ResizeObserver = ResizeObserver;
24-
new MatchMedia();

src/__tests__/utils/utils.test.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@ import { range } from "../../utils/utils";
22

33
describe("range", () => {
44
it("returns an array of values not including the stop argument", () => {
5-
expect(range(1, 2)).toEqual([1]);
6-
expect(range(4, 7)).toEqual([4, 5, 6]);
7-
expect(range(2, 9)).toEqual([2, 3, 4, 5, 6, 7, 8]);
5+
expect(range({ start: 1, stop: 2 })).toEqual([1]);
6+
expect(range({ start: 4, stop: 7 })).toEqual([4, 5, 6]);
7+
expect(range({ start: 2, stop: 9 })).toEqual([2, 3, 4, 5, 6, 7, 8]);
88
});
99

1010
it("returns an array of values skipping by the step argument", () => {
11-
expect(range(1, 10, 2)).toEqual([1, 3, 5, 7, 9]);
12-
expect(range(4, 8, 3)).toEqual([4, 7]);
13-
expect(range(2, 20, 2)).toEqual([2, 4, 6, 8, 10, 12, 14, 16, 18]);
14-
expect(range(2, 20, 4)).toEqual([2, 6, 10, 14, 18]);
15-
expect(range(2, 6, 2)).toEqual([2, 4]);
16-
expect(range(2, 20, 5)).toEqual([2, 7, 12, 17]);
11+
expect(range({ start: 1, stop: 10, step: 2 })).toEqual([1, 3, 5, 7, 9]);
12+
expect(range({ start: 4, stop: 8, step: 3 })).toEqual([4, 7]);
13+
expect(range({ start: 2, stop: 20, step: 2 })).toEqual([
14+
2, 4, 6, 8, 10, 12, 14, 16, 18,
15+
]);
16+
expect(range({ start: 2, stop: 20, step: 4 })).toEqual([2, 6, 10, 14, 18]);
17+
expect(range({ start: 2, stop: 6, step: 2 })).toEqual([2, 4]);
18+
expect(range({ start: 2, stop: 20, step: 5 })).toEqual([2, 7, 12, 17]);
1719
});
1820
});

src/components/Accordion/Accordion.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ the `aria-label` passed to the `Accordion`.
105105

106106
<Canvas of={AccordionStories.WithControls} />
107107

108+
You may pass any Chakra `Box` props, as well as the props below.
109+
108110
<ArgTypes of={AccordionStories.WithControls} />
109111

110112
## Accessibility

src/components/Accordion/Accordion.tsx

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@ import {
44
AccordionItem,
55
AccordionPanel,
66
Box,
7+
BoxProps,
78
chakra,
89
ChakraComponent,
910
} from "@chakra-ui/react";
10-
import React, {
11-
ButtonHTMLAttributes,
12-
forwardRef,
13-
useEffect,
14-
useState,
15-
} from "react";
11+
import React, { forwardRef, useEffect, useState } from "react";
1612

1713
import Icon from "../Icons/Icon";
1814

@@ -26,11 +22,7 @@ export interface AccordionDataProps {
2622
panel: string | React.ReactNode;
2723
}
2824

29-
type HTMLButtonAttributes = Pick<
30-
ButtonHTMLAttributes<HTMLButtonElement>,
31-
"aria-label"
32-
>;
33-
export interface AccordionProps extends HTMLButtonAttributes {
25+
export interface AccordionProps extends Omit<BoxProps, "onChange"> {
3426
/** Array of data to display, and an optional accordionType */
3527
accordionData: AccordionDataProps[];
3628
/** ID that other components can cross reference for accessibility purposes */
@@ -50,12 +42,18 @@ export interface AccordionProps extends HTMLButtonAttributes {
5042
* component. */
5143
userClickedOutside?: boolean;
5244
}
53-
5445
/**
55-
* Get the minus or plus icon depending on whether the accordion
56-
* is open or closed.
46+
* Get the minus or plus icon depending on whether the accordion is open or closed.
5747
*/
58-
const getIcon = (isExpanded = false, index: number, id: string) => {
48+
const getIcon = ({
49+
isExpanded = false,
50+
index,
51+
id,
52+
}: {
53+
isExpanded?: boolean;
54+
index: number;
55+
id: string;
56+
}) => {
5957
const iconName = isExpanded ? "minus" : "plus";
6058
return (
6159
<Icon
@@ -73,27 +71,33 @@ const getIcon = (isExpanded = false, index: number, id: string) => {
7371
* array. This automatically creates the `AccordionButton` and `AccordionPanel`
7472
* combination that is required for the Chakra `Accordion` component.
7573
*/
76-
const getElementsFromData = (
77-
data: AccordionDataProps[] = [],
78-
ariaLabel: string,
79-
id: string,
80-
isAlwaysRendered: boolean = false,
81-
panelMaxHeight: string,
82-
hoveredButtonIndex: number,
83-
setHoveredButtonIndex: React.Dispatch<React.SetStateAction<number>>
84-
) => {
74+
const getElementsFromData = ({
75+
data = [],
76+
ariaLabel,
77+
id,
78+
isAlwaysRendered = false,
79+
panelMaxHeight,
80+
hoveredButtonIndex,
81+
setHoveredButtonIndex,
82+
}: {
83+
data?: AccordionDataProps[];
84+
ariaLabel: string;
85+
id: string;
86+
isAlwaysRendered?: boolean;
87+
panelMaxHeight: string;
88+
hoveredButtonIndex: number;
89+
setHoveredButtonIndex: React.Dispatch<React.SetStateAction<number>>;
90+
}) => {
8591
const colorMapLight = {
8692
default: "ui.white",
8793
warning: "ui.status.primary",
8894
error: "ui.status.secondary",
8995
};
90-
9196
const colorMapDark = {
9297
default: "ui.white",
9398
warning: "ui.status.primary",
9499
error: "dark.ui.error.primary",
95100
};
96-
97101
// For FAQ-style multiple accordions, the button should be bigger.
98102
// Otherwise, use the default.
99103
const numAccordionItems = data?.length;
@@ -212,7 +216,11 @@ const getElementsFromData = (
212216
>
213217
{content.label}
214218
</Box>
215-
{getIcon(isExpanded, index, id)}
219+
{getIcon({
220+
isExpanded,
221+
index,
222+
id,
223+
})}
216224
</AccordionButton>
217225
{(isAlwaysRendered || isExpanded) && panel}
218226
</>
@@ -309,15 +317,15 @@ export const Accordion: ChakraComponent<
309317
ref={ref}
310318
{...rest}
311319
>
312-
{getElementsFromData(
313-
updatedAccordionData,
320+
{getElementsFromData({
321+
data: updatedAccordionData,
314322
ariaLabel,
315323
id,
316324
isAlwaysRendered,
317325
panelMaxHeight,
318326
hoveredButtonIndex,
319-
setHoveredButtonIndex
320-
)}
327+
setHoveredButtonIndex,
328+
})}
321329
</ChakraAccordion>
322330
);
323331
})

src/components/Accordion/accordionChangelogData.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export const changelogData: ChangelogData[] = [
1717
notes: [
1818
"Removes `ariaLabel` prop and instructs developers to use the native HTML attribute instead.",
1919
"Removes `isDarkMode` in favor of Chakra's `_dark` conditional key.",
20+
"Replaces positional function arguments with objects for `getIcon` and `getElementsFromData`.",
21+
"Extends prop definition to include Chakra's `BoxProps`",
2022
],
2123
},
2224
{

src/components/AlphabetFilter/AlphabetFilter.mdx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import { changelogData } from "./alphabetFilterChangelogData";
99

1010
# AlphabetFilter
1111

12-
| Component Version | DS Version |
13-
| ----------------- | ---------- |
14-
| Added | `1.2.0` |
15-
| Latest | `3.5.4` |
12+
| Component Version | DS Version |
13+
| ----------------- | ------------ |
14+
| Added | `1.2.0` |
15+
| Latest | `Prerelease` |
1616

1717
## Table of Contents
1818

@@ -46,6 +46,9 @@ component is addressing and the full list of items should be displayed.
4646

4747
<Canvas of={AlphabetFilterStories.WithControls} />
4848

49+
The `AlphabetFilter` composes a Chakra `Box` component, so you may pass
50+
any Chakra `Box` props, as well as the props below.
51+
4952
<ArgTypes of={AlphabetFilterStories.WithControls} />
5053

5154
## Accessibility

src/components/AlphabetFilter/AlphabetFilter.stories.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const meta: Meta<typeof AlphabetFilter> = {
1010
component: AlphabetFilter,
1111
argTypes: {
1212
activeLetters: { control: false },
13-
className: { control: false },
1413
currentLetter: { control: false },
1514
id: { control: false },
1615
isDisabled: argsBooleanType(),
@@ -28,7 +27,6 @@ type Story = StoryObj<typeof AlphabetFilter>;
2827
export const WithControls: Story = {
2928
args: {
3029
activeLetters: undefined,
31-
className: undefined,
3230
currentLetter: undefined,
3331
descriptionText: "This is description text.",
3432
headingText: "AlphabetFilter",

src/components/AlphabetFilter/AlphabetFilter.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { forwardRef, useRef, useState } from "react";
22
import {
33
Box,
4+
BoxProps,
45
chakra,
56
ChakraComponent,
67
Flex,
@@ -10,12 +11,10 @@ import {
1011
import { Button } from "../Button/Button";
1112
import ComponentWrapper from "../ComponentWrapper/ComponentWrapper";
1213

13-
export interface AlphabetFilterProps {
14+
export interface AlphabetFilterProps extends Omit<BoxProps, "onClick"> {
1415
/** Array of letters to specify which `Button` components should be set in an `enabled`
1516
* state. By default, all buttons are `enabled`. */
1617
activeLetters?: string[];
17-
/** A class name for the AlphabetFilter parent div. */
18-
className?: string;
1918
/** The currentLetter can be used to programatically set the selected letter without the
2019
* user explicitly requesting it. */
2120
currentLetter?: string;
@@ -42,7 +41,6 @@ export const AlphabetFilter: ChakraComponent<
4241
forwardRef<HTMLDivElement, AlphabetFilterProps>((props, ref?) => {
4342
const {
4443
activeLetters,
45-
className,
4644
currentLetter,
4745
descriptionText,
4846
headingText,
@@ -166,7 +164,6 @@ export const AlphabetFilter: ChakraComponent<
166164
<Box as="nav" ref={ref} aria-label="Filter by letter">
167165
<ComponentWrapper
168166
id={id}
169-
className={className}
170167
__css={styles}
171168
{...rest}
172169
headingText={headingText ? headingText : undefined}

src/components/AlphabetFilter/alphabetFilterChangelogData.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
import { ChangelogData } from "../../utils/ComponentChangelogTable";
1010

1111
export const changelogData: ChangelogData[] = [
12+
{
13+
date: "Prerelease",
14+
version: "Prerelease",
15+
type: "Update",
16+
affects: ["Functionality"],
17+
notes: ["Removed explicit `classname` prop."],
18+
},
1219
{
1320
date: "2025-02-13",
1421
version: "3.5.4",

src/components/AudioPlayer/AudioPlayer.mdx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import { changelogData } from "./audioPlayerChangelogData";
99

1010
# Audio Player
1111

12-
| Component Version | DS Version |
13-
| ----------------- | ---------- |
14-
| Added | `1.2.0` |
15-
| Latest | `3.0.0` |
12+
| Component Version | DS Version |
13+
| ----------------- | ------------ |
14+
| Added | `1.2.0` |
15+
| Latest | `Prerelease` |
1616

1717
## Table of Contents
1818

@@ -39,6 +39,9 @@ version of the component.
3939

4040
<Canvas of={AudioPlayerStories.WithControls} />
4141

42+
The `AudioPlayer` composes a Chakra `Box` component, so you may pass
43+
any Chakra `Box` props, as well as the props below.
44+
4245
<ArgTypes of={AudioPlayerStories.WithControls} />
4346

4447
## Accessibility

src/components/AudioPlayer/AudioPlayer.stories.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const meta: Meta<typeof AudioPlayer> = {
1111
control: { type: "radio" },
1212
options: ["file", "libsyn", "soundcloud", "spotify"],
1313
},
14-
className: { control: false },
1514
descriptionText: { control: "text" },
1615
embedCode: { control: false },
1716
headingText: { control: "text" },
@@ -34,7 +33,6 @@ const libsynPlayerEmbedCode =
3433
export const WithControls: Story = {
3534
args: {
3635
audioType: "libsyn",
37-
className: undefined,
3836
descriptionText:
3937
"Audio description lorem ipsum dolor simet. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed posuere consectetur est at lobortis.",
4038
embedCode: libsynPlayerEmbedCode,

src/components/AudioPlayer/AudioPlayer.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
Box,
3+
BoxProps,
34
chakra,
45
ChakraComponent,
56
useMultiStyleConfig,
@@ -16,11 +17,9 @@ const thirdPartyServices = ["libsyn", "soundcloud", "spotify"] as const;
1617
export type ThirdPartyAudioType = typeof thirdPartyServices[number];
1718
export type AudioType = ThirdPartyAudioType | "file";
1819

19-
export interface AudioPlayerProps {
20+
export interface AudioPlayerProps extends BoxProps {
2021
/** Required string used to specify the type of audio playback. */
2122
audioType: AudioType;
22-
/** Optional className you can add in addition to `audio-player`. */
23-
className?: string;
2423
/** Optional string to set the text for the audio player description. */
2524
descriptionText?: string;
2625
/** Optional string to set a code snippet provided by Libsyn, SoundCloud or Spotify; the

src/components/AudioPlayer/audioPlayerChangelogData.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@
99
import { ChangelogData } from "../../utils/ComponentChangelogTable";
1010

1111
export const changelogData: ChangelogData[] = [
12+
{
13+
date: "Prerelease",
14+
version: "Prerelease",
15+
type: "Update",
16+
affects: ["Functionality"],
17+
notes: [
18+
"Removed explicit `className` prop as interface can be extended to include Chakra prop or HTML attribute types.",
19+
],
20+
},
1221
{
1322
date: "2024-03-14",
1423
version: "3.0.0",

0 commit comments

Comments
 (0)