-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
123 additions
and
64 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,27 @@ | ||
import { css, Theme } from "@emotion/react" | ||
import styled from "@emotion/styled" | ||
import * as stylex from "@stylexjs/stylex" | ||
import { theme } from "../../theme.stylex.ts" | ||
import { ComponentPropsWithoutRef, forwardRef } from "react" | ||
|
||
export const CardStyle = (props: { theme: Theme }) => css` | ||
background: ${props.theme.color.card}; | ||
box-shadow: ${props.theme.shadow.card}; | ||
backdrop-filter: blur(30px); | ||
// Define the basic card style | ||
export const cardStyle = stylex.create({ | ||
baseCard: { | ||
boxShadow: theme.shadowCard, | ||
padding: "24px", | ||
borderRadius: "8px", | ||
background: theme.colorCard, | ||
backdropFilter: "blur(30px)", | ||
}, | ||
}) | ||
|
||
@supports not (backdrop-filter: blur(30px)) { | ||
background: ${props.theme.color.cardFallback}; | ||
} | ||
` | ||
|
||
export const Card = styled.div` | ||
padding: 24px; | ||
border-radius: 8px; | ||
${CardStyle} | ||
` | ||
/** | ||
* This is here for styled-component backwards compatibility. | ||
*/ | ||
export const Card = forwardRef<HTMLDivElement, ComponentPropsWithoutRef<"div">>( | ||
({ children, ...props }, ref) => { | ||
return ( | ||
<div ref={ref} {...stylex.props(cardStyle.baseCard)} {...props}> | ||
{children} | ||
</div> | ||
) | ||
}, | ||
) |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import * as stylex from "@stylexjs/stylex" | ||
|
||
const DARK = "@media (prefers-color-scheme: dark)" | ||
const DARK_BLUR = | ||
"@media (prefers-color-scheme: dark) and (@supports (backdrop-filter: blur(30px)))" | ||
|
||
const BLUR = "@supports (backdrop-filter: blur(30px))" | ||
|
||
export const theme = stylex.defineVars({ | ||
colorCard: { | ||
default: "rgba(255, 255, 255, 0.8)", | ||
[BLUR]: "rgba(255, 255, 255, 0.45)", | ||
[DARK]: "rgba(26, 42, 64, 0.85)", | ||
[DARK_BLUR]: "rgba(26, 42, 64, 0.7)", | ||
}, | ||
colorAccent: { default: "#E88840", [DARK]: "#FCBA20" }, | ||
fontColorOverlay: { default: "white", [DARK]: "white" }, // Overlay doesn't change between themes | ||
fontColorNormal: { | ||
default: "rgba(0, 0, 0, 0.85)", | ||
[DARK]: "rgba(255, 255, 255, 0.85)", | ||
}, | ||
fontColorMuted: { | ||
default: "rgba(0, 0, 0, 0.7)", | ||
[DARK]: "rgba(255, 255, 255, 0.7)", | ||
}, | ||
stateColorWarning: { default: "#ff5400", [DARK]: "#ff5400" }, // Assuming warning color doesn't change | ||
gradientOverlay: { | ||
default: | ||
"linear-gradient(0deg, rgba(255,255,255,0.7) 0%, rgba(255,255,255,0.4) 35%)", | ||
[DARK]: "linear-gradient(0deg, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.4) 35%)", | ||
}, | ||
shadowCard: { | ||
default: "3px 3px 11px 1px rgb(0 0 0 / 10%)", | ||
[DARK]: "3px 3px 15px 1px rgb(0 0 0 / 15%)", | ||
}, | ||
}) |