| 1 |
@use '../../sass-utilities' as *; |
| 2 |
|
| 3 |
@include pf-root($radio) { |
| 4 |
--#{$radio}--GridGap: var(--pf-t--global--spacer--sm) var(--pf-t--global--spacer--sm); |
| 5 |
--#{$radio}--AccentColor: var(--pf-t--global--icon--color--brand--default); |
| 6 |
--#{$radio}--m-standalone--MinHeight: calc(var(--#{$radio}__label--FontSize) * var(--#{$radio}__label--LineHeight)); |
| 7 |
|
| 8 |
// TODO: update to `--#{$radio}--FontSize` `--#{$radio}--LineHeight` |
| 9 |
--#{$radio}__label--disabled--Color: var(--pf-t--global--text--color--disabled); |
| 10 |
--#{$radio}__label--Color: var(--pf-t--global--text--color--regular); |
| 11 |
--#{$radio}__label--FontWeight: var(--pf-t--global--font--weight--body--default); |
| 12 |
--#{$radio}__label--FontSize: var(--pf-t--global--font--size--body--default); |
| 13 |
--#{$radio}__label--LineHeight: var(--pf-t--global--font--line-height--body); |
| 14 |
--#{$radio}__description--FontSize: var(--pf-t--global--font--size--body--sm); |
| 15 |
--#{$radio}__description--Color: var(--pf-t--global--text--color--subtle); |
| 16 |
|
| 17 |
// * Radio input |
| 18 |
--#{$radio}__input--first-child--MarginInlineStart: #{pf-size-prem(1px)}; |
| 19 |
--#{$radio}__input--last-child--MarginInlineEnd: #{pf-size-prem(1px)}; |
| 20 |
--#{$radio}__body--MarginBlockStart: var(--pf-t--global--spacer--sm); |
| 21 |
|
| 22 |
// TODO: due to subpixel rendering and this value resolving to 21px, the checkbox vertical centering is off by 1px. Mozilla rounds subpixels up while chrome rounds down. This is a temporary fix until we can find a better solution. |
| 23 |
--#{$radio}__input--TranslateY: calc((var(--#{$radio}__label--LineHeight) * var(--#{$radio}__label--FontSize) / 2 ) - 50%); // find height of single label, divide by two, offset by 50% of own height |
| 24 |
} |
| 25 |
|
| 26 |
// - Radio |
| 27 |
.#{$radio} { |
| 28 |
display: grid; |
| 29 |
grid-template-columns: auto 1fr; |
| 30 |
gap: var(--#{$radio}--GridGap); |
| 31 |
align-items: baseline; |
| 32 |
accent-color: var(--#{$radio}--AccentColor); |
| 33 |
|
| 34 |
&.pf-m-standalone { |
| 35 |
display: inline-grid; |
| 36 |
grid-template-columns: auto; |
| 37 |
min-height: var(--#{$radio}--m-standalone--MinHeight); |
| 38 |
|
| 39 |
.#{$radio}__input { |
| 40 |
align-self: center; |
| 41 |
transform: none; |
| 42 |
} |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
// - Radio input |
| 47 |
.#{$radio}__input { |
| 48 |
align-self: start; |
| 49 |
font-size: var(--#{$radio}__label--FontSize); |
| 50 |
line-height: var(--#{$radio}__label--LineHeight); |
| 51 |
|
| 52 |
// find height of single label, divide by two, offset by 50% of own height |
| 53 |
transform: translateY(var(--#{$radio}__input--TranslateY)); |
| 54 |
|
| 55 |
// fixes a chrome issue where the left edge is cut off in a container with overflow hidden |
| 56 |
&:first-child { |
| 57 |
margin-inline-start: var(--#{$radio}__input--first-child--MarginInlineStart); |
| 58 |
} |
| 59 |
|
| 60 |
// fixes a chrome issue where the right edge is cut off in a container with overflow hidden |
| 61 |
&:last-child { |
| 62 |
margin-inline-end: var(--#{$radio}__input--last-child--MarginInlineEnd); |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
.#{$radio}__label { |
| 67 |
font-size: var(--#{$radio}__label--FontSize); |
| 68 |
font-weight: var(--#{$radio}__label--FontWeight); |
| 69 |
line-height: var(--#{$radio}__label--LineHeight); |
| 70 |
color: var(--#{$radio}__label--Color); |
| 71 |
} |
| 72 |
|
| 73 |
.#{$radio}__description { |
| 74 |
grid-column: 2; |
| 75 |
font-size: var(--#{$radio}__description--FontSize); |
| 76 |
color: var(--#{$radio}__description--Color); |
| 77 |
} |
| 78 |
|
| 79 |
.#{$radio}__body { |
| 80 |
grid-column: 2; |
| 81 |
margin-block-start: var(--#{$radio}__body--MarginBlockStart); |
| 82 |
} |
| 83 |
|
| 84 |
.#{$radio}__label, |
| 85 |
.#{$radio}__input { |
| 86 |
justify-self: start; |
| 87 |
|
| 88 |
@at-root label.#{$radio}, |
| 89 |
& { |
| 90 |
cursor: pointer; |
| 91 |
} |
| 92 |
|
| 93 |
&:disabled, |
| 94 |
&.pf-m-disabled { |
| 95 |
--#{$radio}__label--Color: var(--#{$radio}__label--disabled--Color); |
| 96 |
|
| 97 |
cursor: not-allowed; |
| 98 |
} |
| 99 |
} |