Skip to content

Commit

Permalink
Introduce rem mixin for components
Browse files Browse the repository at this point in the history
  • Loading branch information
sdvg committed Mar 11, 2024
1 parent c588d86 commit 89bb4d5
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 25 deletions.
3 changes: 3 additions & 0 deletions packages/components/src/components/@shared/_mixins.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@function rem($size) {
@return calc(#{$size}rem / var(--kolibri-root-font-size, 16));
}
3 changes: 2 additions & 1 deletion packages/components/src/components/avatar/style.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@import '../@shared/mixins';
@import '../style';
@import '../host-display-block';

Expand Down Expand Up @@ -25,6 +26,6 @@
justify-content: center;
/*theme?*/
background: #d3d3d3;
font-size: 2rem;
font-size: rem(32);
}
}
5 changes: 3 additions & 2 deletions packages/components/src/components/input-range/style.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@import '../@shared/mixins';
@import '../@shared/kol-alert-mixin';
@import '../input-line';
@import '../@shared/kol-alert-mixin.scss';

@include kol-alert-styles;

Expand All @@ -25,7 +26,7 @@
border: 1px solid #000;
display: inline-block;
flex-grow: 1;
height: 0.5rem;
height: rem(8);
line-height: 1.5em;
padding: 0;
margin: 0;
Expand Down
7 changes: 4 additions & 3 deletions packages/components/src/components/input.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@import '@shared/mixins';
@import 'label';
@import 'host-display-block';

Expand Down Expand Up @@ -38,17 +39,17 @@
select,
select[multiple] option,
textarea {
font-size: 1rem;
font-size: rem(16);
width: 100%;
}

/* needed hack for vertical alignment */
input[type='file'] {
padding: calc((var(--a11y-min-size) - 1rem) / 10) 0.5em;
padding: calc((var(--a11y-min-size) - rem(16)) / 10) 0.5em;
}

/* needed hack for vertical alignment */
select[multiple] option {
padding: calc((var(--a11y-min-size) - 1rem) / 2) 0.5em;
padding: calc((var(--a11y-min-size) - rem(16)) / 2) 0.5em;
}
}
9 changes: 5 additions & 4 deletions packages/components/src/components/link-group/style.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@import '../@shared/mixins';
@import '../style';

@layer kol-component {
Expand All @@ -13,8 +14,8 @@
}

nav.horizontal li {
margin-left: 1.25rem;
margin-right: 0.25rem;
margin-left: rem(20);
margin-right: rem(4);
}

nav.horizontal li:first-child {
Expand All @@ -26,8 +27,8 @@
}

nav.vertical li {
margin-left: 1.75rem;
margin-right: 0.5rem;
margin-left: rem(28);
margin-right: rem(8);
}

li.list-none {
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/components/pagination/style.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
@import '../@shared/mixins';
@import '../style';

@layer kol-component {
:host {
align-items: center;
display: grid;
gap: 1rem;
gap: rem(16);
grid-template-columns: 1fr auto;
}

Expand Down
6 changes: 4 additions & 2 deletions packages/components/src/components/spin/cycle.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
@import '../@shared/mixins';

@layer kol-component {
.spin.cycle {
width: 3rem;
height: 3rem;
width: rem(48);
height: rem(48);
}

.spin.cycle > .loader {
Expand Down
24 changes: 13 additions & 11 deletions packages/components/src/components/spin/dot.scss
Original file line number Diff line number Diff line change
@@ -1,45 +1,47 @@
@import '../@shared/mixins';

@layer kol-component {
.spin.dot {
height: 1rem;
width: 3rem;
height: rem(16);
width: rem(48);
}

.spin.dot > span {
animation-timing-function: cubic-bezier(0, 1, 1, 0);
border-radius: 50%;
border: 0.1rem solid #fff;
height: 0.8rem;
border: rem(0.16) solid #fff;
height: rem(12.8);
position: absolute;
top: 0.1rem;
width: 0.8rem;
top: rem(0.16);
width: rem(12.8);
}

.spin.dot > span:first-child {
background-color: #fc0;
z-index: 0;
animation: 1s infinite spin1;
left: 0.1rem;
left: rem(0.16);
}

.spin.dot > span:nth-child(2) {
background-color: red;
z-index: 1;
animation: 1s infinite spin2;
left: 0.1rem;
left: rem(0.16);
}

.spin.dot > span:nth-child(3) {
background-color: #000;
z-index: 1;
animation: 1s infinite spin2;
left: 1.1rem;
left: rem(17.6);
}

.spin.dot > span:nth-child(4) {
background-color: #666;
z-index: 0;
animation: 1s infinite spin3;
left: 2.1rem;
left: rem(33.6);
}

@keyframes spin1 {
Expand All @@ -55,7 +57,7 @@
transform: translate(0, 0);
}
100% {
transform: translate(1rem, 0);
transform: translate(rem(16), 0);
}
}
@keyframes spin3 {
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/components/spin/style.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
@import '../@shared/mixins';
@import '../style';
@import 'cycle';
@import 'dot';

@layer kol-component {
.spin {
display: block;
padding: 0.125rem;
padding: rem(2);
position: relative;
}
}

0 comments on commit 89bb4d5

Please sign in to comment.