Created
December 17, 2023 21:20
-
-
Save matthew-ia/a882e1cd0522032341ccbcd6f6215f56 to your computer and use it in GitHub Desktop.
Utility Classes as Properties Pattern (Svelte)
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
<script> | |
export let top = true; | |
export let bottom = true; | |
export let right = true; | |
export let left = true; | |
</script> | |
<div class:top class:bottom class:left class:right> | |
<slot/> | |
</div> | |
<style type="scss"> | |
$y-padding: 20px; | |
$x-padding: 10px; | |
.top { | |
padding-top: $y-padding; | |
} | |
.bottom { | |
padding-bottom: $y-padding; | |
} | |
.left { | |
padding-left: $x-padding; | |
} | |
.right { | |
padding-right: $x-padding; | |
} | |
</style |
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
<script> | |
import Box from "./Box.svelte"; | |
const section2 = { | |
top: false, | |
left: false, | |
} | |
</script> | |
<Section bottom={false}>One</Section> | |
<Section {...section2}>Two</Section> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment