-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: extract radio button and group styles literals (#6676)
- Loading branch information
1 parent
eb3ee80
commit b8956eb
Showing
6 changed files
with
139 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* @license | ||
* Copyright (c) 2017 - 2023 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
*/ | ||
import type { CSSResult } from 'lit'; | ||
|
||
export const radioButtonStyles: CSSResult; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/** | ||
* @license | ||
* Copyright (c) 2017 - 2023 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
*/ | ||
import { css } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js'; | ||
|
||
export const radioButtonStyles = css` | ||
:host { | ||
display: inline-block; | ||
} | ||
:host([hidden]) { | ||
display: none !important; | ||
} | ||
:host([disabled]) { | ||
-webkit-tap-highlight-color: transparent; | ||
} | ||
.vaadin-radio-button-container { | ||
display: grid; | ||
grid-template-columns: auto 1fr; | ||
align-items: baseline; | ||
} | ||
[part='radio'], | ||
::slotted(input), | ||
::slotted(label) { | ||
grid-row: 1; | ||
} | ||
[part='radio'], | ||
::slotted(input) { | ||
grid-column: 1; | ||
} | ||
[part='radio'] { | ||
width: var(--vaadin-radio-button-size, 1em); | ||
height: var(--vaadin-radio-button-size, 1em); | ||
--_input-border-width: var(--vaadin-input-field-border-width, 0); | ||
--_input-border-color: var(--vaadin-input-field-border-color, transparent); | ||
box-shadow: inset 0 0 0 var(--_input-border-width, 0) var(--_input-border-color); | ||
} | ||
[part='radio']::before { | ||
display: block; | ||
content: '\\202F'; | ||
line-height: var(--vaadin-radio-button-size, 1em); | ||
contain: paint; | ||
} | ||
/* visually hidden */ | ||
::slotted(input) { | ||
opacity: 0; | ||
cursor: inherit; | ||
margin: 0; | ||
align-self: stretch; | ||
-webkit-appearance: none; | ||
width: initial; | ||
height: initial; | ||
} | ||
@media (forced-colors: active) { | ||
[part='radio'] { | ||
outline: 1px solid; | ||
outline-offset: -1px; | ||
} | ||
:host([focused]) [part='radio'] { | ||
outline-width: 2px; | ||
} | ||
:host([disabled]) [part='radio'] { | ||
outline-color: GrayText; | ||
} | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* @license | ||
* Copyright (c) 2017 - 2023 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
*/ | ||
import type { CSSResult } from 'lit'; | ||
|
||
export const radioGroupStyles: CSSResult; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* @license | ||
* Copyright (c) 2017 - 2023 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
*/ | ||
import { css } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js'; | ||
|
||
export const radioGroupStyles = css` | ||
:host { | ||
display: inline-flex; | ||
} | ||
:host::before { | ||
content: '\\2003'; | ||
width: 0; | ||
display: inline-block; | ||
} | ||
:host([hidden]) { | ||
display: none !important; | ||
} | ||
.vaadin-group-field-container { | ||
display: flex; | ||
flex-direction: column; | ||
width: 100%; | ||
} | ||
[part='group-field'] { | ||
display: flex; | ||
flex-wrap: wrap; | ||
} | ||
:host(:not([has-label])) [part='label'] { | ||
display: none; | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters