Skip to content

Commit 120b978

Browse files
authored
refactor: make globals opt-in for backwards compatibility (#5302)
1 parent a418cc9 commit 120b978

6 files changed

Lines changed: 18 additions & 8 deletions

File tree

‎packages/checkbox/theme/lumo/vaadin-checkbox-styles.js‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ registerStyles(
2222
user-select: none;
2323
cursor: default;
2424
outline: none;
25+
--_checkbox-size: var(--vaadin-checkbox-size, calc(var(--lumo-size-m) / 2));
2526
}
2627
2728
:host([has-label]) ::slotted(label) {
@@ -30,6 +31,8 @@ registerStyles(
3031
}
3132
3233
[part='checkbox'] {
34+
width: var(--_checkbox-size);
35+
height: var(--_checkbox-size);
3336
margin: var(--lumo-space-xs);
3437
position: relative;
3538
border-radius: var(--lumo-border-radius-s);
@@ -49,7 +52,7 @@ registerStyles(
4952
font-family: 'lumo-icons';
5053
content: var(--lumo-icons-checkmark);
5154
color: var(--lumo-primary-contrast-color);
52-
font-size: calc(var(--vaadin-checkbox-size) + 2px);
55+
font-size: calc(var(--_checkbox-size) + 2px);
5356
line-height: 1;
5457
position: absolute;
5558
top: -1px;
@@ -113,6 +116,7 @@ registerStyles(
113116
color: transparent;
114117
width: 100%;
115118
height: 100%;
119+
line-height: var(--_checkbox-size);
116120
border-radius: inherit;
117121
background-color: inherit;
118122
transform: scale(1.4);

‎packages/checkbox/theme/material/vaadin-checkbox-styles.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import '@vaadin/vaadin-material-styles/color.js';
2-
import '@vaadin/vaadin-material-styles/style.js';
32
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
43

54
registerStyles(
@@ -13,13 +12,16 @@ registerStyles(
1312
user-select: none;
1413
outline: none;
1514
-webkit-tap-highlight-color: transparent;
15+
--_checkbox-size: var(--vaadin-checkbox-size, 16px);
1616
}
1717
1818
:host([has-label]) ::slotted(label) {
1919
padding: 3px 12px 3px 6px;
2020
}
2121
2222
[part='checkbox'] {
23+
width: var(--_checkbox-size);
24+
height: var(--_checkbox-size);
2325
margin: 4px;
2426
position: relative;
2527
border-radius: 2px;
@@ -32,6 +34,7 @@ registerStyles(
3234
pointer-events: none;
3335
width: 100%;
3436
height: 100%;
37+
line-height: var(--_checkbox-size);
3538
border-radius: 50%;
3639
background-color: var(--material-disabled-text-color);
3740
transform: scale(0);

‎packages/radio-group/theme/lumo/vaadin-radio-button-styles.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ registerStyles(
2121
user-select: none;
2222
cursor: default;
2323
outline: none;
24+
--_radio-button-size: var(--vaadin-radio-button-size, calc(var(--lumo-size-m) / 2));
2425
}
2526
2627
:host([has-label]) ::slotted(label) {
@@ -29,6 +30,8 @@ registerStyles(
2930
}
3031
3132
[part='radio'] {
33+
width: var(--_radio-button-size);
34+
height: var(--_radio-button-size);
3235
margin: var(--lumo-space-xs);
3336
position: relative;
3437
border-radius: 50%;
@@ -44,6 +47,7 @@ registerStyles(
4447
color: transparent;
4548
width: 100%;
4649
height: 100%;
50+
line-height: var(--_radio-button-size);
4751
border-radius: inherit;
4852
background-color: inherit;
4953
transform: scale(1.4);

‎packages/radio-group/theme/material/vaadin-radio-button-styles.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import '@vaadin/vaadin-material-styles/color.js';
2-
import '@vaadin/vaadin-material-styles/style.js';
32
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
43

54
registerStyles(
@@ -12,13 +11,16 @@ registerStyles(
1211
user-select: none;
1312
outline: none;
1413
-webkit-tap-highlight-color: transparent;
14+
--_radio-button-size: var(--vaadin-radio-button-size, 16px);
1515
}
1616
1717
:host([has-label]) ::slotted(label) {
1818
padding: 4px 0.875em 4px 0.375em;
1919
}
2020
2121
[part='radio'] {
22+
width: var(--_radio-button-size);
23+
height: var(--_radio-button-size);
2224
margin: 4px;
2325
position: relative;
2426
border: 2px solid;
@@ -34,6 +36,7 @@ registerStyles(
3436
color: transparent;
3537
width: 100%;
3638
height: 100%;
39+
line-height: var(--_radio-button-size);
3740
border-radius: inherit;
3841
background-color: var(--material-primary-color);
3942
transform: scale(2.5);

‎packages/vaadin-lumo-styles/style.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const globals = css`
3636
`;
3737

3838
const $tpl = document.createElement('template');
39-
$tpl.innerHTML = `<style>${style.toString().replace(':host', 'html')}${globals.toString()}</style>`;
39+
$tpl.innerHTML = `<style>${style.toString().replace(':host', 'html')}$</style>`;
4040
document.head.appendChild($tpl.content);
4141

4242
export { globals, style };

‎packages/vaadin-material-styles/style.js‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,4 @@ const globals = css`
1616
}
1717
`;
1818

19-
const $tpl = document.createElement('template');
20-
$tpl.innerHTML = `<style>${globals.toString()}</style>`;
21-
document.head.appendChild($tpl.content);
22-
2319
export { globals };

0 commit comments

Comments
 (0)