-
Notifications
You must be signed in to change notification settings - Fork 365
feat(clerk-js): Add colorShadow
variable option
#6290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
alexcarpenter
merged 6 commits into
alexcarpenter/user-2202-add-clerk-css-variable-utilities-for-current-variables
from
alexcarpenter/variables-color-shadow
Jul 14, 2025
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
565e8de
feat(clerk-js): Add `colorShadow` variable option
alexcarpenter e918d24
check for colorMix support
alexcarpenter 0f085f6
shadow generation
alexcarpenter ffc0217
update comment
alexcarpenter e4edc2b
update shadow description
alexcarpenter 1f3a088
Merge branch 'alexcarpenter/user-2202-add-clerk-css-variable-utilitie…
alexcarpenter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,46 @@ | ||
export const shadows = Object.freeze({ | ||
menuShadow: '0px 5px 15px 0px rgba(0, 0, 0, 0.08), 0px 15px 35px -5px rgba(25, 28, 33, 0.20)', | ||
fabShadow: '0px 12px 24px rgba(0, 0, 0, 0.32)', | ||
buttonShadow: | ||
'0px 1px 1px 0px rgba(255, 255, 255, 0.07) inset, 0px 2px 3px 0px rgba(34, 42, 53, 0.20), 0px 1px 1px 0px rgba(0, 0, 0, 0.24)', | ||
cardBoxShadow: '0px 5px 15px 0px rgba(0, 0, 0, 0.08), 0px 15px 35px -5px rgba(25, 28, 33, 0.20)', | ||
cardContentShadow: '0px 0px 2px 0px rgba(0, 0, 0, 0.08), 0px 1px 2px 0px rgba(25, 28, 33, 0.06)', | ||
actionCardShadow: '0px 1px 4px 0px rgba(0, 0, 0, 0.12), 0px 4px 8px 0px rgba(106, 115, 133, 0.12)', | ||
outlineButtonShadow: '0px 2px 3px -1px rgba(0, 0, 0, 0.08), 0px 1px 0px 0px rgba(0, 0, 0, 0.02)', | ||
input: '0px 0px 1px 0px {{color}}', | ||
focusRing: '0px 0px 0px 4px {{color}}', | ||
badge: '0px 2px 0px -1px rgba(0, 0, 0, 0.04)', | ||
tableBodyShadow: | ||
'0px 0px 2px 0px rgba(0, 0, 0, 0.08), 0px 1px 2px 0px rgba(25, 28, 33, 0.12), 0px 0px 0px 1px rgba(0, 0, 0, 0.06)', | ||
segmentedControl: '0px 1px 2px 0px rgba(0, 0, 0, 0.08)', | ||
switchControl: | ||
'0px 2px 2px -1px rgba(0, 0, 0, 0.06), 0px 0px 0px 1px rgba(0, 0, 0, 0.06), 0px 4px 4px -2px rgba(0, 0, 0, 0.06)', | ||
} as const); | ||
import { createAlphaColorMixString } from '../utils/colors/utils'; | ||
import { clerkCssVar } from '../utils/cssVariables'; | ||
import { cssSupports } from '../utils/cssSupports'; | ||
|
||
type ShadowGenerator = (color: string, alpha: number) => string; | ||
|
||
const generateShadow = | ||
(fn: (color: string, alpha: number) => string): ShadowGenerator => | ||
(color: string, alpha: number) => | ||
cssSupports.modernColor() ? fn(color, alpha) : `rgba(0, 0, 0, ${alpha})`; | ||
|
||
/** | ||
* Creates a complete set of shadows using the provided shadow color | ||
* @param shadowColor - The base color to use for shadows (defaults to black) | ||
* @param shadowGenerator - Function to generate shadow colors with alpha (defaults to CSS variable-based generator) | ||
* @returns Object containing all shadow definitions | ||
*/ | ||
export const createShadowSet = ( | ||
shadowColor: string = '#000000', | ||
shadowGenerator: ShadowGenerator = generateShadow((color, alpha) => | ||
createAlphaColorMixString(clerkCssVar('color-shadow', color), alpha * 100), | ||
), | ||
) => { | ||
const highlightColor = '#FFFFFF'; | ||
return { | ||
menuShadow: `0px 5px 15px 0px ${shadowGenerator(shadowColor, 0.08)}, 0px 15px 35px -5px ${shadowGenerator(shadowColor, 0.2)}`, | ||
fabShadow: `0px 12px 24px ${shadowGenerator(shadowColor, 0.32)}`, | ||
buttonShadow: `0px 1px 1px 0px ${shadowGenerator(highlightColor, 0.07)} inset, 0px 2px 3px 0px ${shadowGenerator(shadowColor, 0.2)}, 0px 1px 1px 0px ${shadowGenerator(shadowColor, 0.24)}`, | ||
cardBoxShadow: `0px 5px 15px 0px ${shadowGenerator(shadowColor, 0.08)}, 0px 15px 35px -5px ${shadowGenerator(shadowColor, 0.2)}`, | ||
cardContentShadow: `0px 0px 2px 0px ${shadowGenerator(shadowColor, 0.08)}, 0px 1px 2px 0px ${shadowGenerator(shadowColor, 0.06)}`, | ||
actionCardShadow: `0px 1px 4px 0px ${shadowGenerator(shadowColor, 0.12)}, 0px 4px 8px 0px ${shadowGenerator(shadowColor, 0.12)}`, | ||
outlineButtonShadow: `0px 2px 3px -1px ${shadowGenerator(shadowColor, 0.08)}, 0px 1px 0px 0px ${shadowGenerator(shadowColor, 0.02)}`, | ||
input: '0px 0px 1px 0px {{color}}', | ||
focusRing: '0px 0px 0px 4px {{color}}', | ||
badge: `0px 2px 0px -1px ${shadowGenerator(shadowColor, 0.04)}`, | ||
tableBodyShadow: `0px 0px 2px 0px ${shadowGenerator(shadowColor, 0.08)}, 0px 1px 2px 0px ${shadowGenerator(shadowColor, 0.12)}, 0px 0px 0px 1px ${shadowGenerator(shadowColor, 0.06)}`, | ||
segmentedControl: `0px 1px 2px 0px ${shadowGenerator(shadowColor, 0.08)}`, | ||
switchControl: `0px 2px 2px -1px ${shadowGenerator(shadowColor, 0.06)}, 0px 0px 0px 1px ${shadowGenerator(shadowColor, 0.06)}, 0px 4px 4px -2px ${shadowGenerator(shadowColor, 0.06)}`, | ||
}; | ||
}; | ||
|
||
// Default shadows using black shadow color | ||
export const shadows = Object.freeze(createShadowSet()); | ||
|
||
// Export the generator functions for use in other modules | ||
export { generateShadow }; |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this the case for only
shadows.input
andshadows.focusRing
? Or for none at all ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure I understand the question.