Spaces:
Configuration error
Configuration error
Download web/libs/editor/src/components/Label/Label.jsx from bisalsaha/lebel-studio: direct link, hf CLI and curl.
- Browser
- Download file 1.2 kB
-
https://huggingface.co/spaces/bisalsaha/lebel-studio/resolve/main/web/libs/editor/src/components/Label/Label.jsx
- Command line
-
hf download hf://spaces/bisalsaha/lebel-studio/web/libs/editor/src/components/Label/Label.jsx
-
curl -L -o Label.jsx https://huggingface.co/spaces/bisalsaha/lebel-studio/resolve/main/web/libs/editor/src/components/Label/Label.jsx
1.2 kB
| import chroma from "chroma-js"; | |
| import React, { useMemo } from "react"; | |
| import { cn } from "../../utils/bem"; | |
| import { asVars } from "../../utils/styles"; | |
| import "./Label.prefix.css"; | |
| export const Label = React.forwardRef( | |
| ( | |
| { | |
| className, | |
| style, | |
| color, | |
| empty = false, | |
| hidden = false, | |
| selected = false, | |
| margins = false, | |
| onClick, | |
| children, | |
| hotkey, | |
| ...rest | |
| }, | |
| ref, | |
| ) => { | |
| const styles = useMemo(() => { | |
| if (!color) return null; | |
| const background = chroma(color).alpha(0.15); | |
| return { | |
| ...(style ?? {}), | |
| ...asVars({ | |
| color, | |
| background, | |
| }), | |
| }; | |
| }, [color]); | |
| return ( | |
| <span | |
| ref={ref} | |
| className={cn("label") | |
| .mod({ empty, hidden, selected, clickable: !!onClick, margins }) | |
| .mix(className) | |
| .toClassName()} | |
| style={styles} | |
| onClick={onClick} | |
| {...rest} | |
| > | |
| <span className={cn("label").elem("text").toClassName()}>{children}</span> | |
| {hotkey ? <span className={cn("label").elem("hotkey").toClassName()}>{hotkey}</span> : null} | |
| </span> | |
| ); | |
| }, | |
| ); | |