Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function useTabProps(
_: BootstrapTabOptions,
htmlProps: TabHTMLProps = {}
): TabHTMLProps {
const background = usePalette("background") || "white";
const foreground = usePalette("foreground") || "black";
const borderColor = useFade(foreground, 0.75);
const tab = css`
background-color: transparent;
border: 1px solid transparent;
border-width: 1px 1px 0 1px;
border-radius: 0.25rem 0.25rem 0 0;
font-size: 100%;
padding: 0.5em 1em;
margin: 0 0 -1px 0;
&[aria-selected="true"] {
background-color: ${background};
border-color: ${borderColor};
}
[aria-orientation="vertical"] & {
export function useTooltipProps(
{ unstable_system }: BootstrapTooltipOptions,
htmlProps: TooltipHTMLProps = {}
): TooltipHTMLProps {
const {
style: { backgroundColor }
} = usePaletteBoxProps({ unstable_system });
const fadeBackgroundColor = useFade(backgroundColor || "black", 0.1);
const tooltip = css`
background-color: ${fadeBackgroundColor};
font-size: 0.8em;
padding: 0.5rem;
border-radius: 0.25rem;
z-index: 999;
& > .arrow {
background-color: transparent;
& .stroke {
fill: transparent;
}
& .fill {
fill: ${fadeBackgroundColor};
}
export function useDialogProps(
{ unstable_system }: BootstrapDialogOptions,
htmlProps: DialogHTMLProps = {}
): DialogHTMLProps {
const {
style: { color, backgroundColor }
} = usePaletteBoxProps({ unstable_system });
const foreground = useContrast(backgroundColor) || "black";
const primaryColor = usePalette("primary");
const borderColor = useFade(foreground, 0.75);
const boxShadowColor = useFade(primaryColor || color || foreground, 0.5);
const dialog = css`
position: fixed;
top: 28px;
left: 50%;
transform: translateX(-50%);
border-radius: 0.25rem;
padding: 1em;
max-height: calc(100vh - 56px);
outline: 0;
border: 1px solid ${borderColor};
color: ${color};
z-index: 999;
&:focus {
export function useFormGroupProps(
{ unstable_system }: BootstrapFormGroupOptions,
htmlProps: unstable_FormGroupHTMLProps = {}
): unstable_FormGroupHTMLProps {
const {
style: { backgroundColor, borderColor: originalBorderColor }
} = usePaletteBoxProps({ unstable_system });
const foreground = useContrast(backgroundColor) || "black";
const color = useLighten(foreground, 0.3);
const borderColor = useFade(foreground, 0.75);
const formGroup = css`
display: block;
color: ${color};
border: 1px solid ${originalBorderColor || borderColor};
border-radius: 0.25rem;
padding: 0.5rem 1rem 1rem;
& > * {
display: block;
}
`;
return { ...htmlProps, className: cx(formGroup, htmlProps.className) };
}
unstable_system: { palette = "primary", ...system } = {}
}: BootstrapTabbableOptions,
htmlProps: TabbableHTMLProps = {}
): TabbableHTMLProps {
const {
style: { color, backgroundColor }
} = usePaletteBoxProps({ unstable_system: { palette, ...system } });
const dark = usePalette("dark") || "black";
const background = usePalette("background") || "white";
const backgroundIsLight = useIsLight(background);
const strokeColor = backgroundColor || color || dark;
const contrastRatio = useContrastRatio(background, strokeColor);
const darker = useDarken(strokeColor, contrastRatio < 1.2 ? 0.25 : 0);
const lighter = useLighten(strokeColor, contrastRatio < 1.2 ? 0.25 : 0);
const boxShadowColor = useFade(backgroundIsLight ? darker : lighter, 0.6);
const tabbable = css`
&:not([type="checkbox"]):not([type="radio"]) {
transition: box-shadow 0.15s ease-in-out;
outline: 0;
&:focus {
box-shadow: 0 0 0 0.2em ${boxShadowColor};
position: relative;
z-index: 2;
}
&:hover {
z-index: 2;
}
}
export function useFormInputProps(
{ unstable_system }: BootstrapFormInputOptions,
htmlProps: unstable_FormInputHTMLProps = {}
): unstable_FormInputHTMLProps {
const {
style: { backgroundColor, borderColor: originalBorderColor }
} = usePaletteBoxProps({ unstable_system });
const foreground = useContrast(backgroundColor) || "black";
const color = useLighten(foreground, 0.3);
const primary = usePalette("primary");
const borderColor = useFade(foreground, 0.75);
const focusBorderColor = useLighten(primary, 0.4);
const formInput = css`
display: block;
width: 100%;
border-radius: 0.2rem;
padding: 0.5em 0.75em;
font-size: 100%;
border: 1px solid ${originalBorderColor || borderColor};
color: ${color};
margin: 0 !important;
&:focus {
border-color: ${originalBorderColor || focusBorderColor};
}
`;
export function useSeparatorProps(
_: BootstrapSeparatorOptions,
htmlProps: SeparatorHTMLProps = {}
): SeparatorHTMLProps {
const foreground = usePalette("foreground") || "black";
const borderColor = useFade(foreground, 0.75);
const separator = css`
border: 1px solid ${borderColor};
border-width: 0 1px 0 0;
margin: 0 0.5em;
padding: 0;
width: 0;
height: auto;
&[aria-orientation="horizontal"] {
border-width: 0 0 1px 0;
margin: 0.5em 0;
width: auto;
height: 0;
}
`;
export function usePopoverProps(
{ unstable_system }: BootstrapPopoverOptions,
htmlProps: PopoverHTMLProps = {}
): PopoverHTMLProps {
const {
style: { backgroundColor }
} = usePaletteBoxProps({ unstable_system });
const foreground = useContrast(backgroundColor) || "black";
const borderColor = useFade(foreground, 0.75);
const popover = css`
& > .arrow {
background-color: transparent;
& .stroke {
fill: ${borderColor};
}
& .fill {
fill: ${backgroundColor};
}
}
`;
return { ...htmlProps, className: cx(popover, htmlProps.className) };
}
export function useTabListProps(
_: BootstrapTabListOptions,
htmlProps: TabListHTMLProps = {}
): TabListHTMLProps {
const foreground = usePalette("foreground") || "black";
const borderColor = useFade(foreground, 0.75);
const tabList = css`
display: flex;
flex-direction: row;
border: 1px solid ${borderColor};
border-width: 0 0 1px 0;
margin: 0 0 1em 0;
&[aria-orientation="vertical"] {
flex-direction: column;
border-width: 0 1px 0 0;
margin: 0 1em 0 0;
}
`;
return { ...htmlProps, className: cx(tabList, htmlProps.className) };
export function useDialogProps(
{ unstable_system }: BootstrapDialogOptions,
htmlProps: DialogHTMLProps = {}
): DialogHTMLProps {
const {
style: { color, backgroundColor }
} = usePaletteBoxProps({ unstable_system });
const foreground = useContrast(backgroundColor) || "black";
const primaryColor = usePalette("primary");
const borderColor = useFade(foreground, 0.75);
const boxShadowColor = useFade(primaryColor || color || foreground, 0.5);
const dialog = css`
position: fixed;
top: 28px;
left: 50%;
transform: translateX(-50%);
border-radius: 0.25rem;
padding: 1em;
max-height: calc(100vh - 56px);
outline: 0;
border: 1px solid ${borderColor};
color: ${color};
z-index: 999;
&:focus {
box-shadow: 0 0 0 0.2em ${boxShadowColor};