fixed issue related to dark mode (#30510)

Signed-off-by: Agnieszka Gancarczyk <agancarc@redhat.com>
Co-authored-by: Agnieszka Gancarczyk <agancarc@redhat.com>
This commit is contained in:
agagancarczyk 2024-06-18 08:06:21 +01:00 committed by GitHub
parent 83af3bc455
commit bb4d2ecf92
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 57 additions and 27 deletions

View file

@ -1,6 +1,7 @@
import { useEffect, useRef } from "react"; import { useEffect, useRef } from "react";
import { Icon } from "@patternfly/react-core"; import { Icon } from "@patternfly/react-core";
import { CaretDownIcon } from "@patternfly/react-icons"; import { CaretDownIcon } from "@patternfly/react-icons";
import { mediaQuery } from "../../util";
import "./dropdown-panel.css"; import "./dropdown-panel.css";
type DropdownPanelProps = { type DropdownPanelProps = {
@ -63,7 +64,15 @@ const DropdownPanel: React.FC<DropdownPanelProps> = ({
</Icon> </Icon>
</button> </button>
{searchDropdownOpen && ( {searchDropdownOpen && (
<div className="kc-dropdown-panel-content">{children}</div> <div
className={
mediaQuery?.matches
? "kc-dropdown-panel-content dark-mode"
: "kc-dropdown-panel-content light-mode"
}
>
{children}
</div>
)} )}
</span> </span>
); );

View file

@ -1,9 +1,8 @@
.kc-dropdown-panel { .kc-dropdown-panel {
background-color: transparent; background-color: transparent;
padding: var(--pf-v5-global--spacer--form-element) var(--pf-v5-global--spacer--sm) padding: var(--pf-v5-global--spacer--form-element) var(--pf-v5-global--spacer--sm) var(--pf-v5-global--spacer--form-element)
var(--pf-v5-global--spacer--form-element) var(--pf-v5-global--spacer--sm); var(--pf-v5-global--spacer--sm);
border-color: var(--pf-v5-global--BorderColor--300) border-color: var(--pf-v5-global--BorderColor--300) var(--pf-v5-global--BorderColor--300) var(--pf-v5-global--BorderColor--200)
var(--pf-v5-global--BorderColor--300) var(--pf-v5-global--BorderColor--200)
var(--pf-v5-global--BorderColor--300); var(--pf-v5-global--BorderColor--300);
border-width: var(--pf-v5-global--BorderWidth--sm); border-width: var(--pf-v5-global--BorderWidth--sm);
border-style: solid; border-style: solid;
@ -36,3 +35,11 @@
padding: 0.75rem; padding: 0.75rem;
z-index: 1; z-index: 1;
} }
.light-mode {
background-color: var(--pf-v5-global--Color--light-100);
}
.dark-mode {
background-color: var(--pf-v5-global--BackgroundColor--300);
}

View file

@ -162,7 +162,9 @@ export function UserDataTableAttributeSearchForm({
setSelectAttributeKeyOpen(false); setSelectAttributeKeyOpen(false);
setValue("name", option.name!); setValue("name", option.name!);
}} }}
/> >
{label(t, option.displayName!, option.name)}
</SelectOption>
))} ))}
</KeycloakSelect> </KeycloakSelect>
); );

View file

@ -333,7 +333,9 @@ export const AdminEvents = () => {
} }
> >
{resourceTypes?.map((option) => ( {resourceTypes?.map((option) => (
<SelectOption key={option} value={option} /> <SelectOption key={option} value={option}>
{option}
</SelectOption>
))} ))}
</KeycloakSelect> </KeycloakSelect>
)} )}
@ -399,7 +401,9 @@ export const AdminEvents = () => {
<SelectOption <SelectOption
key={option.toString()} key={option.toString()}
value={option} value={option}
/> >
{option}
</SelectOption>
))} ))}
</KeycloakSelect> </KeycloakSelect>
)} )}

View file

@ -163,7 +163,7 @@ export const RealmSettingsThemesTab = ({
isOpen={adminUIThemeOpen} isOpen={adminUIThemeOpen}
placeholderText={t("selectATheme")} placeholderText={t("selectATheme")}
data-testid="select-admin-theme" data-testid="select-admin-theme"
aria-label="selectAdminTheme" aria-label={t("selectAdminTheme")}
> >
{themeTypes.admin {themeTypes.admin
.filter((theme) => theme.name !== "base") .filter((theme) => theme.name !== "base")

View file

@ -229,6 +229,7 @@ export const EffectiveMessageBundles = ({
<Controller <Controller
name="theme" name="theme"
control={control} control={control}
defaultValue=""
rules={{ rules={{
validate: (value) => (value || "").length > 0, validate: (value) => (value || "").length > 0,
}} }}
@ -252,7 +253,7 @@ export const EffectiveMessageBundles = ({
field.onChange(""); field.onChange("");
}} }}
isOpen={selectThemesOpen} isOpen={selectThemesOpen}
aria-labelledby={t("theme")} aria-label={t("selectTheme")}
chipGroupComponent={ chipGroupComponent={
<ChipGroup> <ChipGroup>
<Chip <Chip
@ -270,14 +271,16 @@ export const EffectiveMessageBundles = ({
{[ {[
<SelectOption <SelectOption
key="theme_placeholder" key="theme_placeholder"
value="Select theme"
label={t("selectTheme")} label={t("selectTheme")}
className="kc__effective_message_bundles_search_theme__placeholder"
isDisabled isDisabled
/>, >
{t("selectTheme")}
</SelectOption>,
].concat( ].concat(
themeNames.map((option) => ( themeNames.map((option) => (
<SelectOption key={option} value={option} /> <SelectOption key={option} value={option}>
{option}
</SelectOption>
)), )),
)} )}
</KeycloakSelect> </KeycloakSelect>
@ -292,6 +295,7 @@ export const EffectiveMessageBundles = ({
<Controller <Controller
name="themeType" name="themeType"
control={control} control={control}
defaultValue=""
rules={{ rules={{
validate: (value) => (value || "").length > 0, validate: (value) => (value || "").length > 0,
}} }}
@ -315,7 +319,7 @@ export const EffectiveMessageBundles = ({
field.onChange(""); field.onChange("");
}} }}
isOpen={selectThemeTypeOpen} isOpen={selectThemeTypeOpen}
aria-labelledby={t("themeType")} aria-label={t("selectThemeType")}
chipGroupComponent={ chipGroupComponent={
<ChipGroup> <ChipGroup>
<Chip <Chip
@ -333,14 +337,16 @@ export const EffectiveMessageBundles = ({
{[ {[
<SelectOption <SelectOption
key="themeType_placeholder" key="themeType_placeholder"
value="Select theme type"
label={t("selectThemeType")} label={t("selectThemeType")}
className="pf-m-plain"
isDisabled isDisabled
/>, >
{t("selectThemeType")}
</SelectOption>,
].concat( ].concat(
themeTypes.map((option) => ( themeTypes.map((option) => (
<SelectOption key={option} value={option} /> <SelectOption key={option} value={option}>
{option}
</SelectOption>
)), )),
)} )}
</KeycloakSelect> </KeycloakSelect>
@ -351,6 +357,7 @@ export const EffectiveMessageBundles = ({
<Controller <Controller
name="locale" name="locale"
control={control} control={control}
defaultValue=""
rules={{ rules={{
validate: (value) => (value || "").length > 0, validate: (value) => (value || "").length > 0,
}} }}
@ -374,7 +381,7 @@ export const EffectiveMessageBundles = ({
field.onChange(""); field.onChange("");
}} }}
isOpen={selectLanguageOpen} isOpen={selectLanguageOpen}
aria-labelledby="language" aria-label={t("selectLanguage")}
chipGroupComponent={ chipGroupComponent={
<ChipGroup> <ChipGroup>
{field.value ? ( {field.value ? (
@ -397,11 +404,11 @@ export const EffectiveMessageBundles = ({
{[ {[
<SelectOption <SelectOption
key="language_placeholder" key="language_placeholder"
value="Select language"
label={t("selectLanguage")} label={t("selectLanguage")}
className="pf-m-plain"
isDisabled isDisabled
/>, >
{t("selectLanguage")}
</SelectOption>,
].concat( ].concat(
combinedLocales.map((option) => ( combinedLocales.map((option) => (
<SelectOption key={option} value={option}> <SelectOption key={option} value={option}>

View file

@ -83,9 +83,10 @@ export function convertAttributeNameToForm<T>(
name: string, name: string,
): PathValue<T, Path<T>> { ): PathValue<T, Path<T>> {
const index = name.indexOf("."); const index = name.indexOf(".");
return `${name.substring(0, index)}.${beerify( return `${name.substring(0, index)}.${beerify(name.substring(index + 1))}` as PathValue<
name.substring(index + 1), T,
)}` as PathValue<T, Path<T>>; Path<T>
>;
} }
export const beerify = <T extends string>(name: T) => export const beerify = <T extends string>(name: T) =>
@ -182,7 +183,7 @@ export const localeToDisplayName = (locale: string, displayLocale: string) => {
}; };
const DARK_MODE_CLASS = "pf-v5-theme-dark"; const DARK_MODE_CLASS = "pf-v5-theme-dark";
const mediaQuery = export const mediaQuery =
window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)"); window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)");
updateDarkMode(mediaQuery?.matches); updateDarkMode(mediaQuery?.matches);