Created
October 3, 2021 16:39
-
-
Save uluhonolulu/4d6bdf6f096b03dbb8380176780dc4e9 to your computer and use it in GitHub Desktop.
Shadows CSS from ["Designing Beautiful Shadows in CSS"](https://www.joshwcomeau.com/css/designing-shadows/)
This file contains hidden or 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 ELEVATIONS = { | |
| small: ` | |
| 0.5px 1px 1px hsl(var(--shadow-color) / 0.7) | |
| `, | |
| medium: ` | |
| 1px 2px 2px hsl(var(--shadow-color) / 0.333), | |
| 2px 4px 4px hsl(var(--shadow-color) / 0.333), | |
| 3px 6px 6px hsl(var(--shadow-color) / 0.333) | |
| `, | |
| large: ` | |
| 1px 2px 2px hsl(var(--shadow-color) / 0.2), | |
| 2px 4px 4px hsl(var(--shadow-color) / 0.2), | |
| 4px 8px 8px hsl(var(--shadow-color) / 0.2), | |
| 8px 16px 16px hsl(var(--shadow-color) / 0.2), | |
| 16px 32px 32px hsl(var(--shadow-color) / 0.2) | |
| ` | |
| } | |
| const Wrapper = styled.div` | |
| --shadow-color: 0deg 0% 50%; | |
| background-color: hsl(0deg 0% 95%); | |
| display: flex; | |
| flex-direction: column; | |
| align-items: center; | |
| gap: 16px; | |
| padding: 32px; | |
| ` | |
| const BlueWrapper = styled(Wrapper)` | |
| --shadow-color: 220deg 60% 50%; | |
| background-color: hsl(220deg 100% 80%); | |
| padding: 32px; | |
| `; | |
| const Box = styled.div` | |
| border-radius: 8px; | |
| background: white; | |
| `; | |
| const SubtleBox = styled(Box)` | |
| width: 50px; | |
| height: 50px; | |
| box-shadow: ${ELEVATIONS.small}; | |
| ` | |
| const ElevatedBox = styled(Box)` | |
| width: 100px; | |
| height: 100px; | |
| box-shadow: ${ELEVATIONS.large}; | |
| ` | |
| render(<> | |
| <Wrapper> | |
| <SubtleBox /> | |
| <ElevatedBox /> | |
| </Wrapper> | |
| <BlueWrapper> | |
| <SubtleBox /> | |
| <ElevatedBox /> | |
| </BlueWrapper> | |
| </>) |
uluhonolulu
commented
Oct 3, 2021
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment