0
0
SASSmarkup~10 mins

Theme switching architecture in SASS - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a CSS variable for the primary color.

SASS
:root { --primary-color: [1]; }
Drag options to blanks, or click blank then click option'
Ablue
Bprimary-color
Ccolor-primary
D#3498db
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name instead of a color value
Forgetting the '#' in the color code
2fill in blank
medium

Complete the Sass code to use the CSS variable for the background color.

SASS
body { background-color: var([1]); }
Drag options to blanks, or click blank then click option'
Abg-color
Bbackground-color
C--background-color
Dbackground
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the dashes in the variable name
Using a property name instead of a variable name
3fill in blank
hard

Fix the error in the Sass mixin to switch themes by setting CSS variables.

SASS
@mixin theme-switch($theme) { :root { [1]: if($theme == 'dark', #222, #fff); } }
Drag options to blanks, or click blank then click option'
A--background-color
Bbackground-color
Cbackground
Dcolor
Attempts:
3 left
💡 Hint
Common Mistakes
Using property names without dashes
Confusing CSS properties with CSS variables
4fill in blank
hard

Fill both blanks to create a Sass map for themes and access the primary color.

SASS
$themes: ( 'light': (primary: #fff), 'dark': (primary: #000) ); $color: map-get(map-get($themes, [1]), [2]);
Drag options to blanks, or click blank then click option'
A'dark'
B'primary'
C'light'
D'secondary'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping theme and color keys
Using keys not defined in the map
5fill in blank
hard

Fill all three blanks to define a Sass function that returns a theme color.

SASS
@function get-theme-color($theme, $color) { @return map-get(map-get($[1], $[2]), $[3]); }
Drag options to blanks, or click blank then click option'
Athemes
Btheme
Ccolor
Dprimary
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong variable names
Confusing parameters with map keys