How to use the reakit-system-palette/Box.useBoxProps function in reakit-system-palette

To help you get started, we’ve selected a few reakit-system-palette examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github reakit / reakit / packages / reakit-system-bootstrap / src / Tabbable.ts View on Github external
export function useTabbableProps(
  {
    // Setting `primary` here and not in `useTabbableOptions` because we want
    // it to default to `primary` only for the tabbable `box-shadow`
    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 {
github reakit / reakit / packages / reakit-system-bootstrap / src / Dialog.ts View on Github external
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};
github reakit / reakit / packages / reakit-system-bootstrap / src / Button.ts View on Github external
export function useButtonProps(
  { unstable_system }: BootstrapButtonOptions,
  htmlProps: ButtonHTMLProps = {}
): ButtonHTMLProps {
  const {
    style: { color, backgroundColor, borderColor = "transparent" }
  } = usePaletteBoxProps({ unstable_system });

  const hoverBackgroundColor = useDarken(
    backgroundColor || color,
    unstable_system.fill !== "opaque" ? 0 : 0.1
  );
  const activeBackgroundColor = useDarken(hoverBackgroundColor, 0.1);
  const hoverBorderColor = useDarken(backgroundColor || color, 0.2);
  const activeBorderColor = useDarken(hoverBorderColor, 0.1);
  const hoverColor = useContrast(hoverBackgroundColor);
  const activeColor = useContrast(activeBackgroundColor);

  const button = css`
    display: inline-flex;
    font-weight: 400;
    align-items: center;
    justify-content: center;
github reakit / reakit / packages / reakit-system-bootstrap / src / Form.ts View on Github external
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;
    }
  `;
github reakit / reakit / packages / reakit-system-bootstrap / src / Form.ts View on Github external
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;
github reakit / reakit / packages / reakit-system-bootstrap / src / Tooltip.ts View on Github external
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 {
github reakit / reakit / packages / reakit-system-bootstrap / src / Box.ts View on Github external
export function useBoxProps(
  { unstable_system }: BootstrapBoxOptions,
  htmlProps: BoxHTMLProps = {}
): BoxHTMLProps {
  const { style } = usePaletteBoxProps({ unstable_system });

  const box = css`
    box-sizing: border-box;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI",
      "Helvetica Neue", Helvetica, Arial, sans-serif, "Apple Color Emoji",
      "Segoe UI Emoji", "Segoe UI Symbol";

    ${style as any}
  `;

  return { ...htmlProps, className: cx(box, htmlProps.className) };
}
github reakit / reakit / packages / reakit-system-bootstrap / src / Popover.ts View on Github external
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};
      }
    }
  `;