SlideShare a Scribd company logo
1 of 39
Download to read offline
Tudor Barbu
@motanelu
#bcnjs
@bcnjs
github.com/barcelonaJS/speakers
h1 {
color: #EB9406;
margin-bottom: 10px;
}
h2 {
color: #1D72DB;
margin-bottom: 5px;
line-height: 16px;
font-size: 14px;
}
p {
margin-bottom: 5px;
line-height: 16px;
font-size: 14px;
}
img {
border: solid 2px #EB9406;
}
a {
color: #EB9406;
}
Same color
Same typography
h1 {
color: #CC0000;
margin-bottom: 10px;
}
h2 {
color: #1D72DB;
margin-bottom: 5px;
line-height: 16px;
font-size: 14px;
}
p {
margin-bottom: 5px;
line-height: 16px;
font-size: 14px;
}
img {
border: solid 2px #EB9406;
}
a {
color: #CC0000;
}
#EB9406
#CC0000
$font-stack: Helvetica, sans-serif
$primary-color: #333
body
font: 100% $font-stack
color: $primary-color
=transform($property)
-webkit-transform: $property
-ms-transform: $property
transform: $property
.box
+include transform(rotate(30deg))
$font-stack: Helvetica, sans-serif;
$primary-color: #333;
body {
font: 100% $font-stack;
color: $primary-color;
}
@mixin transform($property) {
-webkit-transform: $property;
-ms-transform: $property;
transform: $property;
}
.box {
@include transform(rotate(30deg));
}
Sass SCSS - Sassy CSS
h1 {
color: #EB9406;
margin-bottom: 10px;
}
h2 {
color: #1D72DB;
margin-bottom: 5px;
line-height: 16px;
font-size: 14px;
}
p {
margin-bottom: 5px;
line-height: 16px;
font-size: 14px;
}
img {
border: solid 2px #EB9406;
}
a {
color: #EB9406;
}
$primary-color: #EB9406;
$secondary-color: #1D72DB;
@mixin typography() {
margin-bottom: 5px;
line-height: 16px;
font-size: 14px;
}
h1 {
color: $primary-color;
margin-bottom: 10px;
}
h2 {
color: $secondary-color;
@include typography();
}
p {
@include typography();
}
img {
border: solid 2px $primary-color;
}
a {
color: $primary-color;
}
primary
secondary
accent
success
error
warning
info
neutral
normal hover active disabled
Same “distance” between colors
#94A7BC#BFCAD7 #1D72DB #294F78 #15283C#1F3B5A #0C1824
… …
#91D6DC#BDE6EA #5AC2CA #23ADB8 #12575C#1A828A #0B3437
… …
#ECD9B8#F4E8D4 #E3C595 #A2C678 #6D5939#A38655 #413522
… …
…
$color_primary: #294F78;
$color_secondary: #23ADB8;
/* ... */
$color_alert: #A2C678;
$darker_shades = [25%, 50%, ...];
$lighter_shades = [25%, 50%, ...];
$color_primary_D1: #1F3B5A;
$color_primary_D2: #15283C;
$color_primary_D3: #0C1824;
$color_primary_L1: #1D72DB;
$color_primary_L2: #94A7BC;
$color_primary_L3: #BFCAD7;
$color_secondary_D1 = #1A828A;
/* ... */
$tokens = (
color_primary: #294F78,
color_secondary: #23ADB8,
/* ... */
color_alert: #A2C678,
);
$tokens = (
color_primary: #294F78,
color_secondary: #23ADB8,
/* ... */
color_alert: #A2C678,
color_primary_D1: #1F3B5A,
color_primary_D2: #15283C,
color_primary_D3: #0C1824,
color_primary_L1: #1D72DB,
color_primary_L2: #94A7BC,
color_primary_L3: #BFCAD7,
color_secondary_D1: #1A828A
/* ... */
);
@function delta-shades(
$tokens,
$colors: color_primary color_secondary color_accent color_success color_alert color_error color_info,
$dark-shades: ( D1: 25%, D2: 50%, D3: 70%, D4: 90% ),
$light-shades: ( L1: 25%, L2: 50%, L3: 70%, L4: 90% )
) {
$temp: ();
@each $color in $colors {
@each $shade, $percentage in $dark-shades {
$temp: map-merge(
$temp,
('#{$color}-#{$shade}': mix(black, map-get($tokens, $color), $percentage))
);
}
@each $shade, $percentage in $light-shades {
$temp: map-merge(
$temp,
('#{$color}-#{$shade}': mix(white, map-get($tokens, $color), $percentage))
);
}
}
@return $temp;
};
$palette: (
color-primary: #2b91c1,
color-secondary: #d57c1b,
color-accent: #00cea5,
color-success: #8bc34a,
color-alert: #f5a623,
color-error: #f44c23,
color-info: #0d79ff
);
$palette: delta-shades($palette);
.primary-button:hover {
background-color: map-get($palette, color-primary_D1);
}
.secondary-button:hover {
background-color: map-get($palette, color-secondary_D1);
}
OMG!
It works!
Does it really?
yarn add sass-true --dev
@import 'true';
@import '../../src/scss/delta-shades.scss';
@include describe('delta-shades()') {
@include it('runs with custom parameters') {
$palette: (
color_primary: #f442d1,
color_secondary: #f4b841
);
$shades: delta-shades($palette, color_primary color_secondary,
(DS1: 30%, DS2: 60%), (LS1: 30%, LS2: 60%)
);
@include assert-equal(
map-get($shades, color_primary-DS2), mix(black, #f442d1, 60%)
);
@include assert-equal(
map-get($shades, color_primary-LS1), mix(white, #f442d1, 30%)
);
@include assert-equal(
map-get($shades, color_secondary-LS2), mix(white, #f4b841, 60%)
);
}
}
.delta-badge__large {
font-size: var(--delta-badge-large_font-size);
font-weight: var(--delta-badge-large_font-weight);
line-height: var(--delta-badge-large_height);
padding: 0 var(--delta-badge-large_padding);
}
.delta-badge__large {
font-size: 14px;
font-weight: bold;
line-height: 32px;
padding: 0 8px;
}
:root {
--delta-badge-large_font-size: 14px;
--delta-badge-large_font-weight: bold;
--delta-badge-large_height: 32px;
--delta-badge-large_padding: 8px;
}
@function delta-var($key, $tokens, $export-prefix) {
$use-css-vars: false;
@if (variable_exists(DELTA-USE-CSS-VARS)) {
$use-css-vars: $DELTA-USE-CSS-VARS;
}
@if ($use-css-vars == true) {
@return var(--#{$export-prefix}-#{$key});
} @else {
@return map-get($tokens, $key);
}
}
$tokens: (
large_font-size: 14px,
large_font-weight: bold;
large_height: 32px;
large_padding: 8px;
);
.delta-badge__large {
font-size: delta-var(large_font-size, $tokens, delta-badge);
font-weight: delta-var(large_font-weight, $tokens, delta-badge);
line-height: delta-var(large_height, $tokens, delta-badge);
padding: 0 delta-var(large_padding, $tokens, delta-badge);
}
.delta-badge__large {
font-size: 14px;
font-weight: bold;
line-height: 32px;
padding: 0 8px;
}
.delta-badge__large {
font-size: var(--delta-badge-large_font-size);
font-weight: var(--delta-badge-large_font-weight);
line-height: var(--delta-badge-large_height);
padding: 0 var(--delta-badge-large_padding);
}
$DELTA-USE-CSS-VARS: true;
@import 'true';
@import '../../src/scss/delta-var.scss';
@include describe('delta-var()') {
$map: (
primary_color: black,
font_size: 14px
);
@include it('renders CSS values when the flag is false') {
$DELTA-USE-CSS-VARS: false !global;
@include assert() {
@include output {
color: delta-var(primary_color, $map, delta-token);
font-size: delta-var(font_size, $map, delta-token);
}
@include expect {
color: black;
font-size: 14px;
}
}
}
@include it('renders CSS variables when the flag is true') {
$DELTA-USE-CSS-VARS: true !global;
@include assert() {
@include output {
color: delta-var(primary_color, $map, delta-token);
font-size: delta-var(font_size, $map, delta-token);
}
@include expect {
color: var(--delta-token-primary_color);
font-size: var(--delta-token-font_size);
}
}
}
}
●
●
●
Finding the sassy in sass

More Related Content

Similar to Finding the sassy in sass

Stylesheets of the future with Sass and Compass
Stylesheets of the future with Sass and CompassStylesheets of the future with Sass and Compass
Stylesheets of the future with Sass and Compass
Dave Ross
 
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive NewsMobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
Kaelig Deloumeau-Prigent
 
常用的CSS样式备份精华
常用的CSS样式备份精华常用的CSS样式备份精华
常用的CSS样式备份精华
wensheng wei
 
Chapter 6 TemplateWeek 6csshomework.css html {.docx
Chapter 6 TemplateWeek 6csshomework.css  html {.docxChapter 6 TemplateWeek 6csshomework.css  html {.docx
Chapter 6 TemplateWeek 6csshomework.css html {.docx
robertad6
 
Bloggdesign #2 - hawaa.blogg.no
Bloggdesign #2 - hawaa.blogg.noBloggdesign #2 - hawaa.blogg.no
Bloggdesign #2 - hawaa.blogg.no
Hannee92
 
Theme futura suicida não use como base e nem copie
Theme futura suicida não use como base e nem copieTheme futura suicida não use como base e nem copie
Theme futura suicida não use como base e nem copie
Rafaela Souza
 
Theme futura suicida não use como base e nem copie
Theme futura suicida não use como base e nem copieTheme futura suicida não use como base e nem copie
Theme futura suicida não use como base e nem copie
Rafaela Souza
 
Software programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS filesSoftware programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS files
Dinu Suman
 

Similar to Finding the sassy in sass (20)

Work and play with SASS & Compass
Work and play with SASS & CompassWork and play with SASS & Compass
Work and play with SASS & Compass
 
FCIP SASS Talk
FCIP SASS TalkFCIP SASS Talk
FCIP SASS Talk
 
How to Use Sass to Make Your Site More Maintainable
How to Use Sass to Make Your Site More MaintainableHow to Use Sass to Make Your Site More Maintainable
How to Use Sass to Make Your Site More Maintainable
 
Sass
SassSass
Sass
 
Sass, Compass
Sass, CompassSass, Compass
Sass, Compass
 
Stylesheets of the future with Sass and Compass
Stylesheets of the future with Sass and CompassStylesheets of the future with Sass and Compass
Stylesheets of the future with Sass and Compass
 
Wrangling the CSS Beast with Sass
Wrangling the CSS Beast  with SassWrangling the CSS Beast  with Sass
Wrangling the CSS Beast with Sass
 
Tmx9
Tmx9Tmx9
Tmx9
 
Sass - Making CSS fun again.
Sass - Making CSS fun again.Sass - Making CSS fun again.
Sass - Making CSS fun again.
 
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive NewsMobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
 
abosweed.R57
abosweed.R57abosweed.R57
abosweed.R57
 
常用的CSS样式备份精华
常用的CSS样式备份精华常用的CSS样式备份精华
常用的CSS样式备份精华
 
Chapter 6 TemplateWeek 6csshomework.css html {.docx
Chapter 6 TemplateWeek 6csshomework.css  html {.docxChapter 6 TemplateWeek 6csshomework.css  html {.docx
Chapter 6 TemplateWeek 6csshomework.css html {.docx
 
Finding a Better Way to CSS: Navigating Sass with Compass
Finding a Better Way to CSS: Navigating Sass with CompassFinding a Better Way to CSS: Navigating Sass with Compass
Finding a Better Way to CSS: Navigating Sass with Compass
 
Compass, Sass, and the Enlightened CSS Developer
Compass, Sass, and the Enlightened CSS DeveloperCompass, Sass, and the Enlightened CSS Developer
Compass, Sass, and the Enlightened CSS Developer
 
Bloggdesign #2 - hawaa.blogg.no
Bloggdesign #2 - hawaa.blogg.noBloggdesign #2 - hawaa.blogg.no
Bloggdesign #2 - hawaa.blogg.no
 
Theme futura suicida não use como base e nem copie
Theme futura suicida não use como base e nem copieTheme futura suicida não use como base e nem copie
Theme futura suicida não use como base e nem copie
 
Theme futura suicida não use como base e nem copie
Theme futura suicida não use como base e nem copieTheme futura suicida não use como base e nem copie
Theme futura suicida não use como base e nem copie
 
Chapter 13: Colors and Backgrounds
Chapter 13: Colors and BackgroundsChapter 13: Colors and Backgrounds
Chapter 13: Colors and Backgrounds
 
Software programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS filesSoftware programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS files
 

More from Tudor Barbu

More from Tudor Barbu (7)

Web components
Web componentsWeb components
Web components
 
Modern frontend development with VueJs
Modern frontend development with VueJsModern frontend development with VueJs
Modern frontend development with VueJs
 
Building a js widget
Building a js widgetBuilding a js widget
Building a js widget
 
Testing frontends with nightwatch & saucelabs
Testing frontends with nightwatch & saucelabsTesting frontends with nightwatch & saucelabs
Testing frontends with nightwatch & saucelabs
 
Logging with Monolog
Logging with MonologLogging with Monolog
Logging with Monolog
 
CI / CD w/ Codeception
CI / CD w/ CodeceptionCI / CD w/ Codeception
CI / CD w/ Codeception
 
Hack UPC
Hack UPCHack UPC
Hack UPC
 

Recently uploaded

audience research (emma) 1.pptxkkkkkkkkkkkkkkkkk
audience research (emma) 1.pptxkkkkkkkkkkkkkkkkkaudience research (emma) 1.pptxkkkkkkkkkkkkkkkkk
audience research (emma) 1.pptxkkkkkkkkkkkkkkkkk
lolsDocherty
 
Production 2024 sunderland culture final - Copy.pptx
Production 2024 sunderland culture final - Copy.pptxProduction 2024 sunderland culture final - Copy.pptx
Production 2024 sunderland culture final - Copy.pptx
ChloeMeadows1
 

Recently uploaded (17)

I’ll See Y’All Motherfuckers In Game 7 Shirt
I’ll See Y’All Motherfuckers In Game 7 ShirtI’ll See Y’All Motherfuckers In Game 7 Shirt
I’ll See Y’All Motherfuckers In Game 7 Shirt
 
Development Lifecycle.pptx for the secure development of apps
Development Lifecycle.pptx for the secure development of appsDevelopment Lifecycle.pptx for the secure development of apps
Development Lifecycle.pptx for the secure development of apps
 
TORTOGEL TELAH MENJADI SALAH SATU PLATFORM PERMAINAN PALING FAVORIT.
TORTOGEL TELAH MENJADI SALAH SATU PLATFORM PERMAINAN PALING FAVORIT.TORTOGEL TELAH MENJADI SALAH SATU PLATFORM PERMAINAN PALING FAVORIT.
TORTOGEL TELAH MENJADI SALAH SATU PLATFORM PERMAINAN PALING FAVORIT.
 
Thank You Luv I’ll Never Walk Alone Again T shirts
Thank You Luv I’ll Never Walk Alone Again T shirtsThank You Luv I’ll Never Walk Alone Again T shirts
Thank You Luv I’ll Never Walk Alone Again T shirts
 
audience research (emma) 1.pptxkkkkkkkkkkkkkkkkk
audience research (emma) 1.pptxkkkkkkkkkkkkkkkkkaudience research (emma) 1.pptxkkkkkkkkkkkkkkkkk
audience research (emma) 1.pptxkkkkkkkkkkkkkkkkk
 
Premier Mobile App Development Agency in USA.pdf
Premier Mobile App Development Agency in USA.pdfPremier Mobile App Development Agency in USA.pdf
Premier Mobile App Development Agency in USA.pdf
 
Cyber Security Services Unveiled: Strategies to Secure Your Digital Presence
Cyber Security Services Unveiled: Strategies to Secure Your Digital PresenceCyber Security Services Unveiled: Strategies to Secure Your Digital Presence
Cyber Security Services Unveiled: Strategies to Secure Your Digital Presence
 
Bug Bounty Blueprint : A Beginner's Guide
Bug Bounty Blueprint : A Beginner's GuideBug Bounty Blueprint : A Beginner's Guide
Bug Bounty Blueprint : A Beginner's Guide
 
GOOGLE Io 2024 At takes center stage.pdf
GOOGLE Io 2024 At takes center stage.pdfGOOGLE Io 2024 At takes center stage.pdf
GOOGLE Io 2024 At takes center stage.pdf
 
Free scottie t shirts Free scottie t shirts
Free scottie t shirts Free scottie t shirtsFree scottie t shirts Free scottie t shirts
Free scottie t shirts Free scottie t shirts
 
Statistical Analysis of DNS Latencies.pdf
Statistical Analysis of DNS Latencies.pdfStatistical Analysis of DNS Latencies.pdf
Statistical Analysis of DNS Latencies.pdf
 
Production 2024 sunderland culture final - Copy.pptx
Production 2024 sunderland culture final - Copy.pptxProduction 2024 sunderland culture final - Copy.pptx
Production 2024 sunderland culture final - Copy.pptx
 
AI Generated 3D Models | AI 3D Model Generator
AI Generated 3D Models | AI 3D Model GeneratorAI Generated 3D Models | AI 3D Model Generator
AI Generated 3D Models | AI 3D Model Generator
 
iThome_CYBERSEC2024_Drive_Into_the_DarkWeb
iThome_CYBERSEC2024_Drive_Into_the_DarkWebiThome_CYBERSEC2024_Drive_Into_the_DarkWeb
iThome_CYBERSEC2024_Drive_Into_the_DarkWeb
 
Registry Data Accuracy Improvements, presented by Chimi Dorji at SANOG 41 / I...
Registry Data Accuracy Improvements, presented by Chimi Dorji at SANOG 41 / I...Registry Data Accuracy Improvements, presented by Chimi Dorji at SANOG 41 / I...
Registry Data Accuracy Improvements, presented by Chimi Dorji at SANOG 41 / I...
 
The Rise of Subscription-Based Digital Services.pdf
The Rise of Subscription-Based Digital Services.pdfThe Rise of Subscription-Based Digital Services.pdf
The Rise of Subscription-Based Digital Services.pdf
 
Reggie miller choke t shirtsReggie miller choke t shirts
Reggie miller choke t shirtsReggie miller choke t shirtsReggie miller choke t shirtsReggie miller choke t shirts
Reggie miller choke t shirtsReggie miller choke t shirts
 

Finding the sassy in sass

  • 3.
  • 4.
  • 6.
  • 7.
  • 8.
  • 9. h1 { color: #EB9406; margin-bottom: 10px; } h2 { color: #1D72DB; margin-bottom: 5px; line-height: 16px; font-size: 14px; } p { margin-bottom: 5px; line-height: 16px; font-size: 14px; } img { border: solid 2px #EB9406; } a { color: #EB9406; } Same color Same typography
  • 10.
  • 11. h1 { color: #CC0000; margin-bottom: 10px; } h2 { color: #1D72DB; margin-bottom: 5px; line-height: 16px; font-size: 14px; } p { margin-bottom: 5px; line-height: 16px; font-size: 14px; } img { border: solid 2px #EB9406; } a { color: #CC0000; } #EB9406 #CC0000
  • 12.
  • 13.
  • 14. $font-stack: Helvetica, sans-serif $primary-color: #333 body font: 100% $font-stack color: $primary-color =transform($property) -webkit-transform: $property -ms-transform: $property transform: $property .box +include transform(rotate(30deg)) $font-stack: Helvetica, sans-serif; $primary-color: #333; body { font: 100% $font-stack; color: $primary-color; } @mixin transform($property) { -webkit-transform: $property; -ms-transform: $property; transform: $property; } .box { @include transform(rotate(30deg)); } Sass SCSS - Sassy CSS
  • 15.
  • 16.
  • 17. h1 { color: #EB9406; margin-bottom: 10px; } h2 { color: #1D72DB; margin-bottom: 5px; line-height: 16px; font-size: 14px; } p { margin-bottom: 5px; line-height: 16px; font-size: 14px; } img { border: solid 2px #EB9406; } a { color: #EB9406; } $primary-color: #EB9406; $secondary-color: #1D72DB; @mixin typography() { margin-bottom: 5px; line-height: 16px; font-size: 14px; } h1 { color: $primary-color; margin-bottom: 10px; } h2 { color: $secondary-color; @include typography(); } p { @include typography(); } img { border: solid 2px $primary-color; } a { color: $primary-color; }
  • 18.
  • 19.
  • 21. #94A7BC#BFCAD7 #1D72DB #294F78 #15283C#1F3B5A #0C1824 … … #91D6DC#BDE6EA #5AC2CA #23ADB8 #12575C#1A828A #0B3437 … … #ECD9B8#F4E8D4 #E3C595 #A2C678 #6D5939#A38655 #413522 … … …
  • 22. $color_primary: #294F78; $color_secondary: #23ADB8; /* ... */ $color_alert: #A2C678; $darker_shades = [25%, 50%, ...]; $lighter_shades = [25%, 50%, ...]; $color_primary_D1: #1F3B5A; $color_primary_D2: #15283C; $color_primary_D3: #0C1824; $color_primary_L1: #1D72DB; $color_primary_L2: #94A7BC; $color_primary_L3: #BFCAD7; $color_secondary_D1 = #1A828A; /* ... */
  • 23.
  • 24. $tokens = ( color_primary: #294F78, color_secondary: #23ADB8, /* ... */ color_alert: #A2C678, ); $tokens = ( color_primary: #294F78, color_secondary: #23ADB8, /* ... */ color_alert: #A2C678, color_primary_D1: #1F3B5A, color_primary_D2: #15283C, color_primary_D3: #0C1824, color_primary_L1: #1D72DB, color_primary_L2: #94A7BC, color_primary_L3: #BFCAD7, color_secondary_D1: #1A828A /* ... */ );
  • 25. @function delta-shades( $tokens, $colors: color_primary color_secondary color_accent color_success color_alert color_error color_info, $dark-shades: ( D1: 25%, D2: 50%, D3: 70%, D4: 90% ), $light-shades: ( L1: 25%, L2: 50%, L3: 70%, L4: 90% ) ) { $temp: (); @each $color in $colors { @each $shade, $percentage in $dark-shades { $temp: map-merge( $temp, ('#{$color}-#{$shade}': mix(black, map-get($tokens, $color), $percentage)) ); } @each $shade, $percentage in $light-shades { $temp: map-merge( $temp, ('#{$color}-#{$shade}': mix(white, map-get($tokens, $color), $percentage)) ); } } @return $temp; };
  • 26. $palette: ( color-primary: #2b91c1, color-secondary: #d57c1b, color-accent: #00cea5, color-success: #8bc34a, color-alert: #f5a623, color-error: #f44c23, color-info: #0d79ff ); $palette: delta-shades($palette); .primary-button:hover { background-color: map-get($palette, color-primary_D1); } .secondary-button:hover { background-color: map-get($palette, color-secondary_D1); }
  • 29.
  • 31. @import 'true'; @import '../../src/scss/delta-shades.scss'; @include describe('delta-shades()') { @include it('runs with custom parameters') { $palette: ( color_primary: #f442d1, color_secondary: #f4b841 ); $shades: delta-shades($palette, color_primary color_secondary, (DS1: 30%, DS2: 60%), (LS1: 30%, LS2: 60%) ); @include assert-equal( map-get($shades, color_primary-DS2), mix(black, #f442d1, 60%) ); @include assert-equal( map-get($shades, color_primary-LS1), mix(white, #f442d1, 30%) ); @include assert-equal( map-get($shades, color_secondary-LS2), mix(white, #f4b841, 60%) ); } }
  • 32.
  • 33. .delta-badge__large { font-size: var(--delta-badge-large_font-size); font-weight: var(--delta-badge-large_font-weight); line-height: var(--delta-badge-large_height); padding: 0 var(--delta-badge-large_padding); } .delta-badge__large { font-size: 14px; font-weight: bold; line-height: 32px; padding: 0 8px; } :root { --delta-badge-large_font-size: 14px; --delta-badge-large_font-weight: bold; --delta-badge-large_height: 32px; --delta-badge-large_padding: 8px; }
  • 34. @function delta-var($key, $tokens, $export-prefix) { $use-css-vars: false; @if (variable_exists(DELTA-USE-CSS-VARS)) { $use-css-vars: $DELTA-USE-CSS-VARS; } @if ($use-css-vars == true) { @return var(--#{$export-prefix}-#{$key}); } @else { @return map-get($tokens, $key); } }
  • 35. $tokens: ( large_font-size: 14px, large_font-weight: bold; large_height: 32px; large_padding: 8px; ); .delta-badge__large { font-size: delta-var(large_font-size, $tokens, delta-badge); font-weight: delta-var(large_font-weight, $tokens, delta-badge); line-height: delta-var(large_height, $tokens, delta-badge); padding: 0 delta-var(large_padding, $tokens, delta-badge); } .delta-badge__large { font-size: 14px; font-weight: bold; line-height: 32px; padding: 0 8px; } .delta-badge__large { font-size: var(--delta-badge-large_font-size); font-weight: var(--delta-badge-large_font-weight); line-height: var(--delta-badge-large_height); padding: 0 var(--delta-badge-large_padding); } $DELTA-USE-CSS-VARS: true;
  • 36. @import 'true'; @import '../../src/scss/delta-var.scss'; @include describe('delta-var()') { $map: ( primary_color: black, font_size: 14px ); @include it('renders CSS values when the flag is false') { $DELTA-USE-CSS-VARS: false !global; @include assert() { @include output { color: delta-var(primary_color, $map, delta-token); font-size: delta-var(font_size, $map, delta-token); } @include expect { color: black; font-size: 14px; } } } @include it('renders CSS variables when the flag is true') { $DELTA-USE-CSS-VARS: true !global; @include assert() { @include output { color: delta-var(primary_color, $map, delta-token); font-size: delta-var(font_size, $map, delta-token); } @include expect { color: var(--delta-token-primary_color); font-size: var(--delta-token-font_size); } } } }
  • 37.