Skip to content

Commit

Permalink
Update generator.py
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisgoddard authored Nov 9, 2023
1 parent 0d8c191 commit 8c272f7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions utils/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,19 @@ def save_css(path, slug, suffix, css):
# Step 2. b) Create CSS variables for each color
css += ':root {\n'
for color, hex in colors.items():
color = re.sub('\s+', '-', color).lower()
# Should look like --elementary-orange: #f37329;
css += '\t--' + slug + '-' + re.sub('\s+', '-', color).lower() + ': ' + hex.lower() + ';\n'
css += '\t--' + slug + '-' + color + ': ' + hex.lower() + ';\n'
css += '}\n'

# Step 2. c) Create CSS types for each color
for type in types:
for color, hex in colors.items():
color = re.sub('\s+', '-', color).lower()
# Should look like .color-elementary-orange
css += '.' + type + '-' + slug + '-' + re.sub('\s+', '-', color).lower()
css += '.' + type + '-' + slug + '-' + color
# Should look like { color: #f37329; }
css += ' { ' + type + ': var(--' + slug + '); }\n'
css += ' { ' + type + ': var(--' + slug + '-' + color); }\n'

# Step 2. d) Put data into palette.css files
css_all += css
Expand Down

0 comments on commit 8c272f7

Please sign in to comment.