0
0
SASSmarkup~20 mins

Theme switching architecture in SASS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Theme Switching Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
How does CSS custom properties help in theme switching?
Which statement best explains why CSS custom properties (variables) are useful for theme switching in Sass-based projects?
AThey allow dynamic changes to property values without recompiling Sass, enabling runtime theme switching.
BThey force Sass to recompile stylesheets every time the theme changes, improving performance.
CThey replace Sass variables completely, making Sass variables obsolete for theming.
DThey only work with inline styles and cannot be used in external stylesheets.
Attempts:
2 left
💡 Hint
Think about how CSS variables can be changed in the browser after the page loads.
📝 Syntax
intermediate
2:00remaining
Identify the correct Sass syntax for defining a dark theme map
Which option correctly defines a Sass map named $dark-theme with keys 'background' and 'text' and their respective color values?
A$dark-theme: {background: #121212, text: #e0e0e0};
B$dark-theme = (background: #121212; text: #e0e0e0);
C$dark-theme: (background: #121212, text: #e0e0e0);
D$dark-theme: [background: #121212, text: #e0e0e0];
Attempts:
2 left
💡 Hint
Sass maps use parentheses and colons between keys and values.
rendering
advanced
2:00remaining
What color will the text be after applying this Sass theme switch?
Given the following Sass and CSS, what will be the rendered text color in the browser when the dark class is added to the body?
SASS
$light-theme: (background: #ffffff, text: #000000);
$dark-theme: (background: #121212, text: #e0e0e0);

:root {
  --background: map-get($light-theme, background);
  --text: map-get($light-theme, text);
}

body.dark {
  --background: map-get($dark-theme, background);
  --text: map-get($dark-theme, text);
}

body {
  background-color: var(--background);
  color: var(--text);
}
A#e0e0e0
B#000000
C#ffffff
D#121212
Attempts:
2 left
💡 Hint
The dark class changes CSS variables to dark theme values.
selector
advanced
2:00remaining
Which CSS selector correctly applies styles only when dark theme is active?
You want to style all button elements differently when the dark theme is active by adding a dark class to body. Which selector correctly targets buttons only in dark mode?
A.dark > button
Bbutton.dark
Cbody > .dark button
Dbody.dark button
Attempts:
2 left
💡 Hint
The dark class is on the body, not on the button itself.
accessibility
expert
3:00remaining
How to ensure accessible theme switching for color contrast?
When switching themes, what is the best practice to maintain accessibility regarding color contrast?
AUse any colors you like since users can adjust brightness on their devices.
BUse colors that meet WCAG contrast ratios for both light and dark themes to ensure readability.
COnly focus on the light theme's contrast because dark theme is less common.
DUse very bright colors in dark theme to make text stand out regardless of contrast.
Attempts:
2 left
💡 Hint
Think about users with vision impairments and how contrast affects readability.