Skip to content

Commit 22d29cb

Browse files
committed
Remove DisplaySettingDialog to Display for consitency with official website
1 parent 1a8942e commit 22d29cb

File tree

5 files changed

+29
-32
lines changed

5 files changed

+29
-32
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"@emotion/react": "^11.10.4",
7575
"tss-react": "^4.4.4",
7676
"@emotion/styled": "^11.10.4",
77-
"@gouvfr/dsfr": "1.8.5",
77+
"@gouvfr/dsfr": "1.8.4",
7878
"@mui/material": "^5.10.7",
7979
"@storybook/addon-actions": "^6.5.13",
8080
"@storybook/addon-essentials": "^6.5.13",
@@ -127,7 +127,7 @@
127127
"./Notice": "./dist/Notice.js",
128128
"./Highlight": "./dist/Highlight.js",
129129
"./Header": "./dist/Header/index.js",
130-
"./DisplaySettingsDialog": "./dist/DisplaySettingsDialog.js",
130+
"./Display": "./dist/Display.js",
131131
"./Badge": "./dist/Badge.js",
132132
"./Alert": "./dist/Alert.js",
133133
"./Accordion": "./dist/Accordion.js"

src/DisplaySettingsDialog.tsx renamed to src/Display.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import ArtworkSystemSvg from "./dsfr/artwork/system.svg";
1111
import { getAssetUrl } from "./lib/tools/getAssetUrl";
1212
import type { HeaderProps } from "./Header";
1313

14-
export type DisplaySettingsDialog = {
14+
export type Display = {
1515
className?: string;
1616
};
1717

1818
const dialogId = "fr-theme-modal";
1919
const dialogTitleId = "fr-theme-modal-title";
2020

21-
export const headerQuickAccessDisplaySettingsItem: HeaderProps.QuickAccessItem.Button = {
21+
export const headerQuickAccessDisplay: HeaderProps.QuickAccessItem.Button = {
2222
"buttonProps": {
2323
"aria-controls": dialogId,
2424
...({ "data-fr-opened": false } as {})
@@ -34,9 +34,9 @@ export const headerQuickAccessDisplaySettingsItem: HeaderProps.QuickAccessItem.B
3434
})()
3535
};
3636

37-
/** @see <https://react-dsfr-components.etalab.studio/?path=/docs/components-darkmodeswitch> */
38-
export const DisplaySettingsDialog = memo(
39-
forwardRef<HTMLDialogElement, DisplaySettingsDialog>((props, ref) => {
37+
/** @see <https://react-dsfr-components.etalab.studio/?path=/docs/components-display> */
38+
export const Display = memo(
39+
forwardRef<HTMLDialogElement, Display>((props, ref) => {
4040
const { className, ...rest } = props;
4141

4242
assert<Equals<keyof typeof rest, never>>();
@@ -101,9 +101,9 @@ export const DisplaySettingsDialog = memo(
101101
})
102102
);
103103

104-
DisplaySettingsDialog.displayName = symToStr({ DisplaySettingsDialog });
104+
Display.displayName = symToStr({ Display });
105105

106-
export default DisplaySettingsDialog;
106+
export default Display;
107107

108108
const RadioGroup = memo((props: { theme: "dark" | "light" | "system" }) => {
109109
const { theme } = props;
@@ -159,8 +159,8 @@ const RadioGroup = memo((props: { theme: "dark" | "light" | "system" }) => {
159159

160160
RadioGroup.displayName = symToStr({ RadioGroup });
161161

162-
const { useTranslation, addDisplaySettingsDialogTranslations } = createComponentI18nApi({
163-
"componentName": symToStr({ DisplaySettingsDialog }),
162+
const { useTranslation, addDisplayTranslations } = createComponentI18nApi({
163+
"componentName": symToStr({ Display }),
164164
"frMessages": {
165165
/* spell-checker: disable */
166166
"display settings": "Paramètres d'affichage",
@@ -174,7 +174,7 @@ const { useTranslation, addDisplaySettingsDialogTranslations } = createComponent
174174
}
175175
});
176176

177-
addDisplaySettingsDialogTranslations({
177+
addDisplayTranslations({
178178
"lang": "en",
179179
"messages": {
180180
"display settings": "Display settings",
@@ -187,7 +187,7 @@ addDisplaySettingsDialogTranslations({
187187
}
188188
});
189189

190-
addDisplaySettingsDialogTranslations({
190+
addDisplayTranslations({
191191
"lang": "es",
192192
"messages": {
193193
/* spell-checker: disable */
@@ -198,4 +198,4 @@ addDisplaySettingsDialogTranslations({
198198
}
199199
});
200200

201-
export { addDisplaySettingsDialogTranslations };
201+
export { addDisplayTranslations };

stories/DisplaySettingsDialog.stories.tsx renamed to stories/Display.stories.tsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
import * as React from "react";
22
import { Header } from "../dist/Header";
3-
import {
4-
DisplaySettingsDialog,
5-
headerQuickAccessDisplaySettingsItem
6-
} from "../dist/DisplaySettingsDialog";
3+
import { Display, headerQuickAccessDisplay } from "../dist/Display";
74
import { sectionName } from "./sectionName";
85
import { getStoryFactory } from "./getStory";
96
import { symToStr } from "tsafe/symToStr";
107

118
const { meta, getStory } = getStoryFactory({
129
sectionName,
13-
"wrappedComponent": { [symToStr({ DisplaySettingsDialog })]: Story },
10+
"wrappedComponent": { [symToStr({ Display })]: Story },
1411
"description": `
1512
A button that opens a dialog to enable the user to select light or dark mode.
1613
1714
- [See DSFR documentation](https://www.systeme-de-design.gouv.fr/elements-d-interface/composants/parametres-d-affichage),
18-
- [See source code](https://github.com/codegouvfr/react-dsfr/blob/main/src/DisplaySettingsDialog.tsx)
15+
- [See source code](https://github.com/codegouvfr/react-dsfr/blob/main/src/Display.tsx)
1916
2017
Optionally, you can also use \`import { useIsDark } from "@codegouvfr/react-dsfr"\` to manually monitor and controls
2118
the theme state.
@@ -24,7 +21,7 @@ the theme state.
2421
2522
\`\`\`tsx
2623
import { Header } from "../dist/Header";
27-
import { DisplaySettingsDialog, headerQuickAccessDisplaySettingsItem } from "../dist/DisplaySettingsDialog";
24+
import { Display, headerQuickAccessDisplay } from "../dist/Display";
2825
2926
function App(){
3027
@@ -34,11 +31,11 @@ function App(){
3431
// other header props...
3532
quickAccessItems={[
3633
// other quick access items...
37-
headerQuickAccessDisplaySettingsItem
34+
headerQuickAccessDisplay
3835
]}
3936
>
4037
{/* ... your app ...*/}
41-
<DisplaySettingsDialog />
38+
<Display />
4239
<>
4340
);
4441
@@ -63,9 +60,9 @@ function Story() {
6360
}
6461
serviceTitle="Nom du site / service"
6562
homeLinkProps={{ "href": "#" }}
66-
quickAccessItems={[headerQuickAccessDisplaySettingsItem]}
63+
quickAccessItems={[headerQuickAccessDisplay]}
6764
/>
68-
<DisplaySettingsDialog />
65+
<Display />
6966
</>
7067
);
7168
}

test/integration/next/pages/_app.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { AppProps } from "next/app";
22
import { useRouter } from "next/router";
33
import { createNextDsfrIntegrationApi } from "@codegouvfr/react-dsfr/next";
4-
import { DisplaySettingsDialog, headerQuickAccessDisplaySettingsItem } from "@codegouvfr/react-dsfr/DisplaySettingsDialog";
4+
import { Display, headerQuickAccessDisplay } from "@codegouvfr/react-dsfr/Display";
55
import { Header } from "@codegouvfr/react-dsfr/Header";
66
import { createEmotionSsrAdvancedApproach } from "tss-react/next";
77
import { useStyles } from "tss-react/dsfr";
@@ -67,7 +67,7 @@ function App({ Component, pageProps }: AppProps) {
6767
"isActive": router.asPath === "/mui"
6868
}
6969
]}
70-
quickAccessItems={[headerQuickAccessDisplaySettingsItem]}
70+
quickAccessItems={[headerQuickAccessDisplay]}
7171
/>
7272
<div className={css({
7373
"margin": "auto",
@@ -78,7 +78,7 @@ function App({ Component, pageProps }: AppProps) {
7878
})}>
7979
<Component {...pageProps} />
8080
</div>
81-
<DisplaySettingsDialog />
81+
<Display />
8282
</>
8383
);
8484
}

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,10 +1395,10 @@
13951395
resolved "https://registry.yarnpkg.com/@gar/promisify/-/promisify-1.1.3.tgz#555193ab2e3bb3b6adc3d551c9c030d9e860daf6"
13961396
integrity sha512-k2Ty1JcVojjJFwrg/ThKi2ujJ7XNLYaFGNB/bWT9wGR+oSMJHMa5w+CUq6p/pVrKeNNgA7pCqEcjSnHVoqJQFw==
13971397

1398-
"@gouvfr/dsfr@1.8.5":
1399-
version "1.8.5"
1400-
resolved "https://registry.yarnpkg.com/@gouvfr/dsfr/-/dsfr-1.8.5.tgz#e99d095e99debcce0c41db18989637290d588b78"
1401-
integrity sha512-29L+THvWmYJXztPa0Os5TS9yD2WQbrH7VnCKxkyUXQZQ+6lsGebtz0GdCnLexOWDfCn1y53Mh7+/ihxI/z0Vjw==
1398+
"@gouvfr/dsfr@1.8.4":
1399+
version "1.8.4"
1400+
resolved "https://registry.yarnpkg.com/@gouvfr/dsfr/-/dsfr-1.8.4.tgz#e8f7520973460db3729e57816633f569b0a28260"
1401+
integrity sha512-nWWpeAUUe6ghi3L0wwWkh7AxpAW+IvTdUlm5H0wDdjHTELqs+1Mis6jdU7tC9hxqrW9R5b3RNzhcCOqW6wthYQ==
14021402

14031403
"@humanwhocodes/config-array@^0.5.0":
14041404
version "0.5.0"

0 commit comments

Comments
 (0)