Skip to content

Commit b159d72

Browse files
authored
Merge pull request #33 from LoicArc/feature/disable-dark-mode
feat: Remove display setting selector if dark mode is disabled in the…
2 parents 1f54e1d + 41ca234 commit b159d72

8 files changed

Lines changed: 26 additions & 6 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ https://<your keycloak url>/realms/<your realm>/account?referrer={encodeURICompo
8585

8686
Otherwise the themes will render in dark mode if the user prefers it.
8787
You can also prevent the login theme (not supported with the account theme) to ever render in dark mode
88-
by disabling "dark mode" in the Keycloak Admin Console in the `Realm Configuration` -> `Themes` section.
88+
by disabling "dark mode" in the Keycloak Admin Console in the `Realm Configuration` -> `Themes` section.
89+
If the "Dark Mode" option is disabled there, the "display setting" selector in the footer will no longer be displayed.
8990

9091
# License
9192

src/account/KcContext.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { KcEnvName, ThemeName } from "../kc.gen";
55
export type KcContextExtension = {
66
themeName: ThemeName;
77
properties: Record<KcEnvName, string> & {};
8+
darkMode?: boolean;
89
};
910

1011
export type KcContextExtensionPerPage = {};

src/account/KcPageStory.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ const kcContextExtension: KcContextExtension = {
99
themeName: themeNames[0],
1010
properties: {
1111
...kcEnvDefaults
12-
}
12+
},
13+
darkMode: true
1314
};
1415
const kcContextExtensionPerPage: KcContextExtensionPerPage = {};
1516

src/account/Template.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export default function Template(props: TemplateProps<KcContext, I18n>) {
167167
</div>
168168
</div>
169169

170-
<DsfrFooter accessibility="fully compliant" bottomItems={[headerFooterDisplayItem]} />
170+
<DsfrFooter accessibility="fully compliant" bottomItems={[kcContext.darkMode ? headerFooterDisplayItem : undefined]} />
171171
</div>
172172
);
173173
}

src/account/pages/Account.stories.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ export default meta;
1313
type Story = StoryObj<typeof meta>;
1414

1515
export const Default: Story = {
16-
render: () => <KcPageStory />
16+
render: () => <KcPageStory />
17+
};
18+
19+
export const DefaultDarkModeDisabled: Story = {
20+
render: () => <KcPageStory
21+
kcContext={{
22+
darkMode: false
23+
}}
24+
/>
1725
};
1826

1927
/**

src/login/KcPageStory.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ const kcContextExtension: KcContextExtension = {
1212
},
1313
client: {
1414
baseUrl: "https://my-theme.keycloakify.dev"
15-
}
15+
},
16+
darkMode: true
1617
};
1718
const kcContextExtensionPerPage: KcContextExtensionPerPage = {};
1819

src/login/Template.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ export default function Template(props: Props) {
212212
</div>
213213
</div>
214214
</main>
215-
<DSFRFooter accessibility="fully compliant" bottomItems={[headerFooterDisplayItem]} />
215+
<DSFRFooter accessibility="fully compliant" bottomItems={[kcContext.darkMode ? headerFooterDisplayItem : undefined]} />
216216
</div>
217217
);
218218
}

src/login/pages/Login.stories.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ export const Default: Story = {
1616
render: () => <KcPageStory />
1717
};
1818

19+
export const DefaultDarkModeDisabled: Story = {
20+
render: () => <KcPageStory
21+
kcContext={{
22+
darkMode: false
23+
}}
24+
/>
25+
};
26+
1927
export const WithInvalidCredential: Story = {
2028
render: () => (
2129
<KcPageStory

0 commit comments

Comments
 (0)