This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
const result = "A gist on Github run with npx" | |
console.log(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Html JS class example</title> | |
</head> | |
<body> | |
<h1>HTML JS Class Example</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// First example: using a callback for every line to access theme | |
export const PretendContainer1 = styled.div` | |
background-color: ${({ theme }) => theme.colors.primary}; | |
color: ${({ theme }) => theme.colors.secondary}; | |
padding: ${({ theme }) => theme.spacing.medium}; | |
margin-bottom: ${({ theme }) => theme.spacing.small}; | |
`; | |
// Second example: using a single call back that returns `css` for | |
// a single reusable theme prop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ProviderComposer({ contexts, children }) { | |
return contexts.reduceRight( | |
(kids, parent) => | |
React.cloneElement(parent, { | |
children: kids, | |
}), | |
children | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function styled(css, ...variables) { | |
// . . . | |
const computedCss = css | |
.map( | |
(chunk, index) => | |
// now fires a callback at 'variables[index]' | |
`${chunk}${variables[index] ? variables[index](props) : ''}` | |
) | |
.join('') | |
return computedCss |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function styled(css, ...variables) { | |
const theme = { | |
spacing: { | |
min: '2px', | |
max: '24px', | |
}, | |
colors: { | |
primary: 'coral', | |
secondary: 'peachpuff', | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const theme = { | |
spacing: { | |
min: '2px', | |
max: '24px', | |
}, | |
colors: { | |
primary: 'coral', | |
secondary: 'peachpuff', | |
}, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* To use this function, pass in your damage as the first variable | |
* and your bonus (modifier) as the second variable. | |
* | |
* optional: Start the string with what happens to you for flavor. | |
* @example: | |
* doDamage`${18}${3}` | |
* doDamage`trip on a stone${7}${3}` | |
* */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function taggedTemplate(stringArray, variable) { | |
console.log(stringArray) | |
// [ 'The string will be split here: ', ' Then it resumes here.' ] | |
console.log(variable) | |
// I am the great divider! | |
return `${stringArray[0]}${variable}${stringArray[1]}` | |
} |
NewerOlder