Skip to content

Commit 7aa6762

Browse files
committed
🐛 add spaces back to pattern names
and add dashes back to ids
1 parent 1741c12 commit 7aa6762

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

www/src/main.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,21 @@ const markup = name => {
2323
if (random(1, 2) === 1) [c1, c2] = [c2, c1]
2424
const alpha = genAlpha()
2525

26+
// create strings from function name
27+
const id = name.replace(/([A-Z])/g, '-$1').toLowerCase()
28+
const formatName = name.replace(/([A-Z])/g, ' $1')
29+
2630
// generate code example
2731
const params = alpha === 1 ? `'${c2}'` : `'${c2}', ${alpha}`
2832
const functionCode = `${name}(${params})`
2933

3034
// generate actual markup
31-
const id = name.toLowerCase()
32-
const heroFunction = hero[name]
33-
const style = `background-position: center; background-color: ${c1}; background-image: ${heroFunction(c2, alpha)}`
35+
const style = `background-position: center; background-color: ${c1}; background-image: ${hero[name](c2, alpha)}`
3436
const html = `
3537
<div class="hero w-100 w-50-ns w-third-m w-25-l fl" id="${id}" role="presentation">
3638
<div class="hide-child aspect-ratio aspect-ratio--16x9" style="${style}">
3739
<div class="child aspect-ratio--object bg-black-70 flex flex-column items-center justify-center pa3">
38-
<span class="white f5 f4-ns f3-l fw4 ttu tracked tc mt0 mb2">${name}</span>
40+
<span class="white f5 f4-ns f3-l fw4 ttu tracked tc mt0 mb2">${formatName}</span>
3941
<code class="mt2 pv2 ph3 ba b--white br2 code white f6 f5-ns">${functionCode}</code>
4042
</div>
4143
</div>

0 commit comments

Comments
 (0)