Reset
@@ -263,17 +303,23 @@ export const FormIntegration: Story = {
},
};
-function formHandler(e: any) {
+function formHandler(e: any, updateArgs: Function) {
if (e.type === 'submit') e.preventDefault();
setTimeout(() => {
const formOutput = document.querySelector('#AssociatedFormOutput');
- const formData = Array.from(new FormData(e.target).entries()).reduce(
+ const formData: { [key: string]: string } = Array.from(new FormData(e.target).entries()).reduce(
(acc, [k, v]) => Object.assign(acc, { [k]: v }),
{},
);
- if (formOutput) formOutput.innerHTML = JSON.stringify(formData, null, 2);
+ if (formOutput) {
+ updateArgs({
+ validity: e.type === 'reset' ? 'null' : (formData.checkbox !== undefined).toString(),
+ radioValidity: e.type === 'reset' ? 'null' : (formData.radio !== undefined).toString(),
+ });
+ formOutput.innerHTML = JSON.stringify(formData, null, 2);
+ }
});
}
diff --git a/packages/documentation/src/stories/components/forms/card-control/web-component/card-control.styles.scss b/packages/documentation/src/stories/components/forms/card-control/web-component/card-control.styles.scss
new file mode 100644
index 0000000000..e82562cf2b
--- /dev/null
+++ b/packages/documentation/src/stories/components/forms/card-control/web-component/card-control.styles.scss
@@ -0,0 +1,9 @@
+// This is necessary, because we overrite the css classes by a custom control
+// which removes the hydrated class from the componentn,
+// which then causes the component to be visibly hidden
+
+#story--886fabcf-148b-4054-a2ec-4869668294fb--lined-up {
+ post-card-control {
+ visibility: visible;
+ }
+}
diff --git a/packages/documentation/src/stories/components/forms/choice-card/checkbox-card.docs.mdx b/packages/documentation/src/stories/components/forms/choice-card/checkbox-card.docs.mdx
deleted file mode 100644
index 83c674bbe2..0000000000
--- a/packages/documentation/src/stories/components/forms/choice-card/checkbox-card.docs.mdx
+++ /dev/null
@@ -1,66 +0,0 @@
-import { Canvas, Controls, Meta, Source } from '@storybook/blocks';
-import * as CheckboxCardStories from './checkbox-card.stories';
-import StylesPackageImport from '../../../../shared/styles-package-import.mdx';
-import firefoxFallbackSnippet from './firefox-fallback.ts?raw';
-
-
-
-
- # Checkbox card
-
-
-
-
-
-
-
- A larger, more consumer oriented, touch friendly variant of the checkbox used for e.g. selecting
- services.
-
-
-
-
-
-
-
-## Firefox fallback
-
-
- Firefox currently does not support{' '}
-
- the new CSS :has pseudo-selector
-
- . As a fallback, the following states have to be mirrored on the top level element in the form of
- classes (see below for a snippet):
-
-
- checked
-
-
- focused
-
-
- disabled
-
-
- is-invalid
-
-
- Check
caniuse :has() to check if you still need the
- fallback.
-
-
-This snippet adds a global event listener to mirror the `focused` and `checked` states to the parent of the input. This fallback has to be applied as long as Firefox does not support the `:has` selector.
-
-
-
-## Grouping
-
-Checkbox cards can be grouped together. Use a `fieldset`/`legend` combination to label the group. If there is an error, link the legend with the error message through the `aria-describedby` attribute on the `legend`, pointing to the `id` of the error message.
-
-
-
-
-
-
-
diff --git a/packages/documentation/src/stories/components/forms/choice-card/checkbox-card.stories.ts b/packages/documentation/src/stories/components/forms/choice-card/checkbox-card.stories.ts
deleted file mode 100644
index 6d54e3ce02..0000000000
--- a/packages/documentation/src/stories/components/forms/choice-card/checkbox-card.stories.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-import { choiceCardDefault, choiceCardGroup, choiceCardMeta } from './choice-card';
-import { MetaComponent } from '../../../../../types';
-
-const meta: MetaComponent = {
- ...choiceCardMeta,
- id: '9637bbae-0533-4522-89d4-c2732431c69b',
- title: 'Components/Forms/Checkbox Card',
- tags: ['package:HTML'],
- parameters: {
- badges: [],
- design: {
- type: 'figma',
- url: 'https://www.figma.com/file/xZ0IW0MJO0vnFicmrHiKaY/Components-Post?type=design&node-id=22630-6854&mode=design&t=3lniLiZhl7q9Gqgn-4',
- },
- },
-};
-
-export default meta;
-
-export const Default = {
- render: choiceCardDefault,
- args: { ...choiceCardMeta.args, type: 'checkbox' },
- parameters: {
- controls: {
- exclude: ['Group Validation'],
- },
- },
-};
-
-export const Group = {
- render: choiceCardGroup,
- args: { ...choiceCardMeta.args, type: 'checkbox' },
- parameters: {
- controls: {
- include: ['Group Validation'],
- },
- },
-};
diff --git a/packages/documentation/src/stories/components/forms/choice-card/choice-card.ts b/packages/documentation/src/stories/components/forms/choice-card/choice-card.ts
deleted file mode 100644
index 29942999c9..0000000000
--- a/packages/documentation/src/stories/components/forms/choice-card/choice-card.ts
+++ /dev/null
@@ -1,249 +0,0 @@
-import type { Args } from '@storybook/web-components';
-import { html } from 'lit/static-html.js';
-import { classMap } from 'lit/directives/class-map.js';
-import { BADGE } from '../../../../../.storybook/constants';
-import { nothing } from 'lit';
-import { useArgs } from '@storybook/preview-api';
-import { MetaExtended } from '../../../../../types';
-
-export const choiceCardMeta: MetaExtended = {
- parameters: {
- badges: [BADGE.NEEDS_REVISION],
- controls: {
- exclude: ['Type'],
- },
- },
- args: {
- label: 'Card check text',
- type: 'radio',
- checked: false,
- disabled: false,
- focused: false,
- validation: 'null',
- showDescription: false,
- description: 'A small description',
- icon: 1000,
- showIcon: false,
- groupValidation: 'null',
- },
- argTypes: {
- label: {
- name: 'Label',
- type: 'string',
- description: 'The main label of the input',
- table: {
- category: 'General',
- },
- },
- type: {
- name: 'Type',
- control: {
- type: 'radio',
- labels: {
- radio: 'Radio button',
- checkbox: 'Checkbox',
- },
- },
- options: ['radio', 'checkbox'],
- table: {
- // Hide it in the controls because there are two pages
- disable: true,
- },
- },
- checked: {
- name: 'Checked',
- type: 'boolean',
- description: 'When set to `true`, places the component in the checked state.',
- table: {
- category: 'States',
- },
- },
- disabled: {
- name: 'Disabled',
- description:
- 'When set to `true`, disables the component\'s functionality and places it in a disabled state.
There are accessibility concerns with the disabled state. Please read our disabled state accessibility guide . ',
- control: {
- type: 'boolean',
- },
- table: {
- category: 'States',
- },
- },
- focused: {
- name: 'Focused',
- description: 'Render the component in a focused state',
- control: { type: 'boolean' },
- table: {
- category: 'States',
- },
- },
- validation: {
- name: 'Validation',
- description: "Controls the display of the component's validation state.",
- control: {
- type: 'radio',
- labels: {
- 'null': 'Default',
- 'is-invalid': 'Invalid',
- },
- },
- options: ['null', 'is-invalid'],
- table: {
- category: 'States',
- },
- },
- showDescription: {
- name: 'Show description',
- type: 'boolean',
- description: 'Toggles an additional description',
- table: {
- category: 'Description',
- },
- },
- description: {
- name: 'Description',
- type: 'string',
- description: 'A short additional description',
- table: {
- category: 'Description',
- },
- },
- showIcon: {
- name: 'Show icon',
- type: 'boolean',
- description: 'Show or hide icon',
- table: {
- category: 'Icon',
- },
- },
- icon: {
- name: 'Icon',
- control: {
- type: 'select',
- },
- options: [1000, 1001, 2000],
- table: {
- category: 'Icon',
- },
- },
- groupValidation: {
- name: 'Group Validation',
- description: 'Set validation status for the whole group of choice cards',
- control: {
- type: 'radio',
- labels: {
- 'null': 'Default',
- 'is-invalid': 'Invalid',
- },
- },
- options: ['null', 'is-invalid'],
- },
- },
-};
-
-let id_ct = 1;
-
-export const choiceCardDefault = (args: Args) => {
- const [_, updateArgs] = useArgs();
-
- // Conditional classes
- const inputClasses = classMap({
- 'form-check-input': true,
- 'is-invalid': args.validation === 'is-invalid',
- });
- const cardClassMap = classMap({
- 'checked': args.checked,
- 'disabled': args.disabled,
- 'is-invalid': args.validation === 'is-invalid',
- 'checkbox-button-card': args.type === 'checkbox',
- 'radio-button-card': args.type === 'radio',
- });
-
- // Child components
- const id = `control-${id_ct++}`;
- const description = html`
-
-
${args.description}
- `;
- const icon = html`
`;
-
- // Firefox fallback for the :has selector
- const _handleInput = (e: InputEvent) => {
- const target = e.target as HTMLInputElement;
- updateArgs({ checked: target.checked });
-
- // Fix input events not fired on "deselected" radio buttons
- target
- .closest('fieldset')
- ?.querySelectorAll('.radio-button-card')
- .forEach(e => e?.classList.remove('checked'));
- target.parentElement?.classList.toggle('checked', target.checked);
- };
-
- // Firefox fallback for the :has selector
- const _handleFocus = (e: InputEvent) => {
- updateArgs({ focused: true });
- (e.target as HTMLInputElement).parentElement?.classList.add('focused');
- };
-
- // Firefox fallback for the :has selector
- const _handleBlur = (e: InputEvent) => {
- updateArgs({ focused: false });
- (e.target as HTMLInputElement).parentElement?.classList.remove('focused');
- };
-
- return html`
-
-
-
- ${args.label}
- ${args.showDescription ? description : nothing}
-
- ${args.showIcon ? icon : nothing}
-
- `;
-};
-
-export const choiceCardGroup = (args: Args) => {
- const loop = ['One', 'Two', 'Three', 'Four', 'Five', 'Six'];
-
- const col = (label: string) => html`
-
- ${choiceCardDefault({
- ...args,
- label,
- checked: false,
- focused: false,
- validation: args.groupValidation,
- inputName: 'group',
- })}
-
- `;
-
- const error = html`
-
Invalid choice
- `;
-
- return html`
-
-
- Legend
-
- ${loop.map(n => col(n))}
- ${args.groupValidation === 'is-invalid' ? error : null}
-
- `;
-};
diff --git a/packages/documentation/src/stories/components/forms/choice-card/firefox-fallback.ts b/packages/documentation/src/stories/components/forms/choice-card/firefox-fallback.ts
deleted file mode 100644
index 94640a0b61..0000000000
--- a/packages/documentation/src/stories/components/forms/choice-card/firefox-fallback.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-['focusin', 'focusout', 'input'].forEach(t =>
- document.addEventListener(t, e => {
- if (!(e.target instanceof Element) || e.target.nodeName !== 'input') return;
- const parent = e.target.parentElement;
- if (!parent?.classList.contains('radio-button-card')) return;
- switch (e.type) {
- case 'focusin':
- parent.classList.add('focused');
- break;
- case 'focusout':
- parent.classList.remove('focused');
- break;
- case 'input':
- parent.classList.toggle('checked', (e.target as HTMLInputElement).checked);
- break;
- }
- }),
-);
diff --git a/packages/documentation/src/stories/components/forms/choice-card/radiobutton-card.docs.mdx b/packages/documentation/src/stories/components/forms/choice-card/radiobutton-card.docs.mdx
deleted file mode 100644
index 3c7690e702..0000000000
--- a/packages/documentation/src/stories/components/forms/choice-card/radiobutton-card.docs.mdx
+++ /dev/null
@@ -1,66 +0,0 @@
-import { Canvas, Controls, Meta, Source } from '@storybook/blocks';
-import * as RadiobuttonCardStories from './radiobutton-card.stories';
-import StylesPackageImport from '../../../../shared/styles-package-import.mdx';
-import firefoxFallbackSnippet from './firefox-fallback.ts?raw';
-
-
-
-
- # Radio button card
-
-
-
-
-
-
-
- A larger, more consumer oriented, touch friendly variant of the radio-button used for e.g.
- selecting services.
-
-
-
-
-
-
-
-## Firefox fallback
-
-
- Firefox currently does not support{' '}
-
- the new CSS :has pseudo-selector
-
- . As a fallback, the following states have to be mirrored on the top level element in the form of
- classes:
-
-
- checked
-
-
- focused
-
-
- disabled
-
-
- is-invalid
-
-
- Check
caniuse :has() to check if you still need the
- fallback.
-
-
-This snippet adds a global event listener to mirror the `focused` and `checked` states to the parent of the input. This fallback has to be applied as long as Firefox does not support the `:has` selector.
-
-
-
-## Grouping
-
-Radiobutton cards can be grouped together. Use a `fieldset`/`legend` combination to label the group. If there is an error, link the legend with the error message through the `aria-describedby` attribute on the `legend`, pointing to the `id` of the error message.
-
-
-
-
-
-
-
diff --git a/packages/documentation/src/stories/components/forms/choice-card/radiobutton-card.stories.ts b/packages/documentation/src/stories/components/forms/choice-card/radiobutton-card.stories.ts
deleted file mode 100644
index b518d2c551..0000000000
--- a/packages/documentation/src/stories/components/forms/choice-card/radiobutton-card.stories.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import { choiceCardDefault, choiceCardGroup, choiceCardMeta } from './choice-card';
-import { MetaComponent } from '../../../../../types';
-
-const meta: MetaComponent = {
- ...choiceCardMeta,
- title: 'Components/Forms/Radio Button Card',
- tags: ['package:HTML'],
- parameters: {
- badges: [],
- design: {
- type: 'figma',
- url: 'https://www.figma.com/file/xZ0IW0MJO0vnFicmrHiKaY/Components-Post?type=design&node-id=24497-16195&mode=design&t=3lniLiZhl7q9Gqgn-4',
- },
- },
-};
-
-export default meta;
-
-export const Default = {
- render: choiceCardDefault,
- args: { ...choiceCardMeta.args, type: 'radio' },
- parameters: {
- controls: {
- exclude: ['Group Validation'],
- },
- },
-};
-
-export const Group = {
- render: choiceCardGroup,
- args: { ...choiceCardMeta.args, type: 'radio' },
- parameters: { controls: { include: ['Group Validation'] } },
-};
diff --git a/packages/documentation/tsconfig.json b/packages/documentation/tsconfig.json
index e2d8655ef1..65eda9d0b2 100644
--- a/packages/documentation/tsconfig.json
+++ b/packages/documentation/tsconfig.json
@@ -1,5 +1,8 @@
{
"compilerOptions": {
+ "paths": {
+ "@/*": ["./src/*"]
+ },
"target": "ESNext",
"useDefineForClassFields": false,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
diff --git a/packages/documentation/vite.config.js b/packages/documentation/vite.config.js
index e5c4c09df2..774072d041 100644
--- a/packages/documentation/vite.config.js
+++ b/packages/documentation/vite.config.js
@@ -1,7 +1,11 @@
+import { fileURLToPath, URL } from 'url';
// https://vitejs.dev/config/
/** @type {import('vite').UserConfig} */
export default {
+ resolve: {
+ alias: [{ find: '@', replacement: fileURLToPath(new URL('./src', import.meta.url)) }],
+ },
optimizeDeps: {
include: [
'@pxtrn/storybook-addon-docs-stencil',
diff --git a/packages/styles/src/components/_index.scss b/packages/styles/src/components/_index.scss
index 287e24d725..f003b7e37f 100644
--- a/packages/styles/src/components/_index.scss
+++ b/packages/styles/src/components/_index.scss
@@ -9,9 +9,9 @@
@use 'button';
@use 'button-group';
@use 'card';
-@use 'chip';
-@use 'choice-control-card';
+@use 'card-control';
@use 'carousel';
+@use 'chip';
@use 'close';
@use 'elevation';
@use 'error-container';
diff --git a/packages/styles/src/components/card-control.scss b/packages/styles/src/components/card-control.scss
new file mode 100644
index 0000000000..20732b63a8
--- /dev/null
+++ b/packages/styles/src/components/card-control.scss
@@ -0,0 +1,280 @@
+@use '../variables/color';
+@use '../variables/commons';
+@use '../variables/spacing';
+@use '../variables/components/forms';
+@use '../mixins/utilities';
+
+fieldset {
+ .radio-button-card,
+ .checkbox-button-card {
+ &:not(:last-child) {
+ margin-bottom: spacing.$size-regular;
+ }
+ }
+}
+
+.radio-button-card,
+.checkbox-button-card {
+ --post-card-control-border-color: #{color.$gray-60};
+ --post-card-control-bg: #{color.$white};
+ --post-card-control-color: #{color.$gray-80};
+ --post-card-control-input-border-color: #{color.$gray-80};
+ --post-card-control-input-bg: #{color.$white};
+
+ display: grid;
+ grid-template: 'input label icon' 'input content icon' / min-content auto min-content;
+ gap: 0 spacing.$size-mini;
+ position: relative;
+ padding: spacing.$size-regular;
+ width: 100%;
+ background-color: var(--post-card-control-bg);
+ border: spacing.$size-line solid var(--post-card-control-border-color);
+ border-radius: commons.$border-radius;
+ color: var(--post-card-control-color);
+ cursor: pointer;
+
+ input.form-check-input {
+ grid-area: input;
+ position: relative;
+ z-index: 2;
+ margin: spacing.$size-micro 0;
+ background-color: var(--post-card-control-input-bg);
+ border-color: var(--post-card-control-input-border-color) !important;
+ color: var(--post-card-control-input-border-color) !important;
+ cursor: inherit;
+ transition: none;
+
+ &:focus,
+ &:focus-visible {
+ box-shadow: none;
+ }
+
+ ~ label.form-check-label {
+ color: inherit !important;
+ }
+
+ @include utilities.high-contrast-mode() {
+ &::after {
+ forced-color-adjust: none;
+ border-color: transparent;
+ }
+ }
+ }
+
+ label.form-check-label {
+ grid-area: label;
+ margin: spacing.$size-micro 0;
+ padding: 0;
+ border-radius: inherit;
+ transition-duration: 100ms;
+
+ &::before {
+ display: block;
+ content: '';
+ position: absolute;
+ inset: spacing.$size-line * -1;
+ border-radius: inherit;
+ }
+
+ > * {
+ display: block;
+ // Lift content above the :before element to make it selectable
+ position: relative;
+ z-index: 2;
+ }
+ }
+
+ post-icon {
+ grid-area: icon;
+ width: spacing.$size-big;
+ height: spacing.$size-big;
+ pointer-events: none;
+ }
+
+ .card-control--content {
+ grid-area: content;
+ }
+
+ &:where(:not(:has(input:disabled)), :not(.disabled)) {
+ &:where(:has(input:checked), .checked) {
+ --post-card-control-border-color: #{color.$black};
+ --post-card-control-bg: #{color.$yellow};
+
+ @include utilities.high-contrast-mode() {
+ --post-card-control-border-color: FieldText;
+ --post-card-control-bg: SelectedItem;
+ --post-card-control-color: SelectedItemText;
+ --post-card-control-input-border-color: SelectedItemText;
+ --post-card-control-input-bg: SelectedItem;
+
+ input.form-check-input {
+ &::after {
+ background-color: var(--post-card-control-color) !important;
+ }
+ }
+ }
+ }
+
+ &:where(:has(input:invalid), :has(input[aria-invalid]), :has(input.is-invalid), .is-invalid) {
+ --post-card-control-border-color: #{color.$error};
+ --post-card-control-color: #{color.$error};
+ --post-card-control-input-border-color: #{color.$error};
+ }
+
+ &:where(:hover) {
+ --post-card-control-border-color: #{color.$gray-80};
+ --post-card-control-bg: #{color.$gray-60};
+ --post-card-control-color: #{color.$white};
+ --post-card-control-input-border-color: #{color.$black};
+
+ @include utilities.high-contrast-mode() {
+ --post-card-control-border-color: Highlight;
+ --post-card-control-bg: Field;
+ --post-card-control-color: FieldText;
+ --post-card-control-input-border-color: Highlight;
+ --post-card-control-input-bg: Field;
+
+ input.form-check-input {
+ &::after {
+ color: FieldText;
+ }
+ }
+ }
+ }
+
+ input:focus-visible ~ label::before {
+ outline-offset: forms.$input-focus-outline-thickness;
+ outline: forms.$input-focus-outline-thickness solid commons.$outline-color;
+ }
+ }
+
+ &:where(:has(input:disabled), .disabled) {
+ --post-card-control-border-color: #{color.$gray-60};
+ --post-card-control-bg: transparent;
+ --post-card-control-color: #{color.$gray-60};
+ --post-card-control-input-border-color: #{color.$gray-60};
+ --post-card-control-input-bg: transparent;
+
+ border-style: dashed;
+ text-decoration: line-through;
+ cursor: default;
+
+ input.form-check-input {
+ border-style: dashed;
+ }
+
+ @include utilities.high-contrast-mode() {
+ --post-card-control-border-color: GrayText;
+ --post-card-control-color: GrayText;
+ --post-card-control-input-border-color: GrayText;
+
+ &:where(:has(input:checked), .checked) {
+ --post-card-control-input-bg: Field;
+
+ input.form-check-input {
+ outline: spacing.$size-line solid Field;
+ }
+
+ label.form-check-label::before {
+ inset: spacing.$size-line;
+ border-radius: spacing.$size-line;
+ background-color: SelectedItem;
+ }
+ }
+ }
+ }
+}
+
+@each $bg in color.$dark-backgrounds {
+ #{$bg} {
+ .radio-button-card,
+ .checkbox-button-card {
+ --post-card-control-border-color: #{color.$white};
+ --post-card-control-bg: transparent;
+ --post-card-control-color: #{color.$white};
+ --post-card-control-input-border-color: #{color.$white};
+ --post-card-control-input-bg: transparent;
+
+ &:where(:not(:has(input:disabled)), :not(.disabled)) {
+ &:where(:has(input:checked), .checked) {
+ --post-card-control-border-color: #{color.$yellow};
+ --post-card-control-bg: #{color.$yellow};
+ --post-card-control-color: #{color.$gray-80};
+ --post-card-control-input-border-color: #{color.$gray-80};
+ --post-card-control-input-bg: #{color.$white};
+
+ @include utilities.high-contrast-mode() {
+ --post-card-control-border-color: FieldText;
+ --post-card-control-bg: SelectedItem;
+ --post-card-control-color: SelectedItemText;
+ --post-card-control-input-border-color: SelectedItemText;
+ --post-card-control-input-bg: SelectedItem;
+ }
+ }
+
+ &:where(
+ :has(input:invalid),
+ :has(input[aria-invalid]),
+ :has(input.is-invalid),
+ .is-invalid
+ ) {
+ --post-card-control-border-color: #{color.$error};
+ --post-card-control-bg: #{color.$error-background};
+ --post-card-control-color: #{color.$error};
+ --post-card-control-input-border-color: #{color.$error};
+ --post-card-control-input-bg: #{color.$white};
+
+ &:where(:has(input:checked), .checked) {
+ --post-card-control-bg: #{color.$yellow};
+
+ @include utilities.high-contrast-mode() {
+ --post-card-control-border-color: FieldText;
+ --post-card-control-bg: SelectedItem;
+ --post-card-control-color: SelectedItemText;
+ --post-card-control-input-border-color: SelectedItemText;
+ --post-card-control-input-bg: SelectedItem;
+ }
+ }
+ }
+
+ &:where(:hover) {
+ --post-card-control-border-color: #{color.$black};
+ --post-card-control-bg: #{color.$gray-20};
+ --post-card-control-color: #{color.$black};
+ --post-card-control-input-border-color: #{color.$black};
+ --post-card-control-input-bg: #{color.$white};
+
+ @include utilities.high-contrast-mode() {
+ --post-card-control-border-color: Highlight;
+ --post-card-control-bg: Field;
+ --post-card-control-color: FieldText;
+ --post-card-control-input-border-color: Highlight;
+ --post-card-control-input-bg: Field;
+ }
+ }
+
+ input:focus-visible ~ label::before {
+ outline-color: color.$white;
+ }
+ }
+
+ &:where(:has(input:disabled), .disabled) {
+ --post-card-control-border-color: post.$white-alpha-80;
+ --post-card-control-bg: transparent;
+ --post-card-control-color: post.$white-alpha-80;
+ --post-card-control-input-border-color: post.$white-alpha-80;
+ --post-card-control-input-bg: transparent;
+
+ @include utilities.high-contrast-mode() {
+ --post-card-control-border-color: GrayText;
+ --post-card-control-color: GrayText;
+ --post-card-control-input-border-color: GrayText;
+
+ &:where(:has(input:checked), .checked) {
+ --post-card-control-input-bg: Field;
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/packages/styles/src/components/choice-control-card.scss b/packages/styles/src/components/choice-control-card.scss
deleted file mode 100644
index 27f4dca3f3..0000000000
--- a/packages/styles/src/components/choice-control-card.scss
+++ /dev/null
@@ -1,148 +0,0 @@
-@use '../variables/color';
-@use '../variables/commons';
-@use '../variables/spacing';
-@use '../mixins/utilities';
-
-.radio-button-card,
-.checkbox-button-card {
- --post-card-select--hover-bg: #{color.$gray-10};
-
- position: relative;
- display: flex;
- gap: 0 spacing.$size-mini;
-
- width: 100%;
-
- color: color.$gray-80;
- background-color: color.$white;
- border: 2px solid color.$gray-60;
- border-radius: commons.$border-radius;
- padding: spacing.$size-regular;
- transition:
- color 100ms ease-in-out,
- background-color 100ms ease-in-out,
- border-color 100ms ease-in-out;
-
- // Checked
- &:where(:has(input:checked), .checked) {
- --post-card-select--hover-bg: #{color.$yellow};
- background-color: color.$yellow;
- border-color: color.$gray-60;
-
- input {
- background-color: color.$white !important;
- }
- }
-
- // Focus
- &:where(:has(input:focus-visible), .focused) {
- background-color: var(--post-card-select--hover-bg);
- outline: 2px solid color.$black;
- outline-offset: 2px;
- border-color: color.$black;
-
- input {
- border-color: color.$black;
- }
- }
-
- // Hover
- &:where(:hover:not(:has(input:disabled)), :hover:not(.disabled)) {
- border-color: color.$black;
- color: color.$black;
- background-color: var(--post-card-select--hover-bg);
-
- input {
- border-color: color.$black;
- }
-
- @include utilities.high-contrast-mode() {
- border-color: Highlight;
- transition: none;
- }
- }
-
- // Disabled
- &:has(input:disabled),
- &.disabled {
- border-color: color.$gray-20;
- color: color.$gray-40 !important;
-
- > * {
- cursor: default;
- }
- }
-
- &:has(input:disabled:checked),
- &.disabled.checked {
- background-color: color.$gray-10;
- }
-
- // Error
- &:has(input[aria-invalid]),
- &:has(input.is-invalid),
- &.is-invalid {
- color: color.$error;
- border-color: color.$error;
-
- ~ .invalid-feedback {
- display: block;
- }
- }
-
- &:last-child {
- margin-bottom: 0;
- }
-
- > * {
- cursor: pointer;
- }
-
- post-icon {
- width: 2em;
- height: 2em;
- margin-left: spacing.$size-mini;
- pointer-events: none;
- }
-
- input {
- border-color: color.$gray-80;
- background-color: color.$white;
- transition: border-color 100ms ease-in-out;
- grid-column: 1 / 2;
-
- &:focus {
- box-shadow: none !important;
- }
- }
-
- .form-check-label {
- padding-left: 0;
-
- &::before {
- // This spans up the click area of the label to the whole
- // card in order to make it clickable natively.
- content: '';
- position: absolute;
- inset: -2px;
- }
-
- span {
- // Lift spans above the before element to make them selectable
- position: relative;
- }
- }
-
- input,
- .form-check-label {
- margin-block: 0.25rem;
- }
-
- // Align input and label if there is an icon
- &:has(post-icon) {
- input,
- .form-check-label {
- margin-top: 0.25rem;
- }
- }
-}