diff --git a/web/src/admin/blueprints/BlueprintForm.ts b/web/src/admin/blueprints/BlueprintForm.ts index 8d2f7b1f8..3176ddb0e 100644 --- a/web/src/admin/blueprints/BlueprintForm.ts +++ b/web/src/admin/blueprints/BlueprintForm.ts @@ -9,12 +9,11 @@ import "@goauthentik/elements/forms/SearchSelect"; import YAML from "yaml"; import { msg } from "@lit/localize"; -import { CSSResult, TemplateResult, css, html } from "lit"; +import { CSSResult, TemplateResult, html } from "lit"; import { customElement, state } from "lit/decorators.js"; import { ifDefined } from "lit/directives/if-defined.js"; import PFContent from "@patternfly/patternfly/components/Content/content.css"; -import PFToggleGroup from "@patternfly/patternfly/components/ToggleGroup/toggle-group.css"; import { BlueprintFile, BlueprintInstance, ManagedApi } from "@goauthentik/api"; @@ -51,15 +50,7 @@ export class BlueprintForm extends ModelForm { } static get styles(): CSSResult[] { - return super.styles.concat( - PFToggleGroup, - PFContent, - css` - .pf-c-toggle-group { - justify-content: center; - } - `, - ); + return [...super.styles, PFContent]; } async send(data: BlueprintInstance): Promise { diff --git a/web/src/admin/policies/PolicyBindingForm.ts b/web/src/admin/policies/PolicyBindingForm.ts index e7db91957..098a57546 100644 --- a/web/src/admin/policies/PolicyBindingForm.ts +++ b/web/src/admin/policies/PolicyBindingForm.ts @@ -5,12 +5,11 @@ import { ModelForm } from "@goauthentik/elements/forms/ModelForm"; import "@goauthentik/elements/forms/SearchSelect"; import { msg } from "@lit/localize"; -import { CSSResult, css } from "lit"; +import { CSSResult } from "lit"; import { TemplateResult, html } from "lit"; import { customElement, property, state } from "lit/decorators.js"; import PFContent from "@patternfly/patternfly/components/Content/content.css"; -import PFToggleGroup from "@patternfly/patternfly/components/ToggleGroup/toggle-group.css"; import { CoreApi, @@ -70,15 +69,7 @@ export class PolicyBindingForm extends ModelForm { } static get styles(): CSSResult[] { - return super.styles.concat( - PFToggleGroup, - PFContent, - css` - .pf-c-toggle-group { - justify-content: center; - } - `, - ); + return [...super.styles, PFContent]; } send(data: PolicyBinding): Promise { diff --git a/web/src/admin/providers/proxy/ProxyProviderForm.ts b/web/src/admin/providers/proxy/ProxyProviderForm.ts index 8e1f29381..0bd5ac252 100644 --- a/web/src/admin/providers/proxy/ProxyProviderForm.ts +++ b/web/src/admin/providers/proxy/ProxyProviderForm.ts @@ -9,13 +9,12 @@ import "@goauthentik/elements/forms/SearchSelect"; import "@goauthentik/elements/utils/TimeDeltaHelp"; import { msg } from "@lit/localize"; -import { CSSResult, TemplateResult, css, html } from "lit"; +import { CSSResult, TemplateResult, html } from "lit"; import { customElement, state } from "lit/decorators.js"; import { ifDefined } from "lit/directives/if-defined.js"; import PFContent from "@patternfly/patternfly/components/Content/content.css"; import PFList from "@patternfly/patternfly/components/List/list.css"; -import PFToggleGroup from "@patternfly/patternfly/components/ToggleGroup/toggle-group.css"; import PFSpacing from "@patternfly/patternfly/utilities/Spacing/spacing.css"; import { @@ -35,17 +34,7 @@ import { @customElement("ak-provider-proxy-form") export class ProxyProviderFormPage extends ModelForm { static get styles(): CSSResult[] { - return super.styles.concat( - PFToggleGroup, - PFContent, - PFList, - PFSpacing, - css` - .pf-c-toggle-group { - justify-content: center; - } - `, - ); + return [...super.styles, PFContent, PFList, PFSpacing]; } async loadInstance(pk: number): Promise { @@ -114,6 +103,7 @@ export class ProxyProviderFormPage extends ModelForm { > +<<<<<<< HEAD { "User/Group Attribute used for the password part of the HTTP-Basic Header.", )} > - `; +`; + } + + renderModeSelector(): TemplateResult { + const setMode = (ev: CustomEvent<{ value: ProxyMode }>) => { + this.mode = ev.detail.value; + }; + + // prettier-ignore + return html` + + + + + + `; } renderSettings(): TemplateResult { @@ -303,6 +308,7 @@ export class ProxyProviderFormPage extends ModelForm {
+<<<<<<< HEAD
{
+======= +
${this.renderModeSelector()}
+>>>>>>> ak-toggle-group
diff --git a/web/src/components/ak-toggle-group.ts b/web/src/components/ak-toggle-group.ts index 7e8d0eae2..be3382891 100644 --- a/web/src/components/ak-toggle-group.ts +++ b/web/src/components/ak-toggle-group.ts @@ -9,6 +9,19 @@ import PFToggleGroup from "@patternfly/patternfly/components/ToggleGroup/toggle- type Pair = [string, string]; +/** + * Toggle Group + * + * An implementation of the Patternfly Toggle Group as a LitElement + * + * @element ak-toggle-group + * + * @fires ak-toggle - Fired when someone clicks on a toggle option. Carries the value of the option. + */ + +// MYNIS: +// A 'name' property so that the event carries *which* toggle group emitted the event. + @customElement("ak-toggle-group") export class AkToggleGroup extends CustomEmitterElement(AKElement) { static get styles() { @@ -22,6 +35,11 @@ export class AkToggleGroup extends CustomEmitterElement(AKElement) { ]; } + /* + * The value (causes highlighting, value is returned) + * + * @attr + */ @property({ type: String, reflect: true }) value = ""; diff --git a/web/src/components/stories/ak-toggle-group.stories.ts b/web/src/components/stories/ak-toggle-group.stories.ts new file mode 100644 index 000000000..31b2e6c7f --- /dev/null +++ b/web/src/components/stories/ak-toggle-group.stories.ts @@ -0,0 +1,67 @@ +import "@goauthentik/elements/messages/MessageContainer"; +import { Meta } from "@storybook/web-components"; + +import { TemplateResult, html } from "lit"; + +import "../ak-toggle-group"; +import AkToggleGroup from "../ak-toggle-group"; + +const metadata: Meta = { + title: "Components / Toggle Group", + component: "ak-toggle-group", + parameters: { + docs: { + description: { + component: "A stylized toggle control", + }, + }, + }, +}; + +export default metadata; + +const LIGHT = "pf-t-light"; +function injectTheme() { + setTimeout(() => { + if (!document.body.classList.contains(LIGHT)) { + document.body.classList.add(LIGHT); + } + }); +} + +const container = (testItem: TemplateResult) => { + injectTheme(); + return html`
+ + ${testItem} +
    +
    `; +}; + +const testOptions = [ + ["funky", "Option One: The Funky One"], + ["invalid", "Option Two: The Invalid One"], + ["weird", "Option Three: The Weird One"], +]; + +export const ToggleGroup = () => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const displayChange = (ev: any) => { + document.getElementById( + "toggle-message-pad", + )!.innerText = `Value selected: ${ev.detail.value}`; + }; + + return container( + html` + ${testOptions.map(([key, label]) => html``)} + `, + ); +};