How to use the reakit-system-palette/utils/fade.useFade 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 / Tab.ts View on Github external
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"] & {
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 {
        fill: ${fadeBackgroundColor};
      }
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};
    color: ${color};
    z-index: 999;

    &:focus {
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;
    }
  `;

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

    &:focus {
      border-color: ${originalBorderColor || focusBorderColor};
    }
  `;
github reakit / reakit / packages / reakit-system-bootstrap / src / Separator.ts View on Github external
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;
    }
  `;
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};
      }
    }
  `;

  return { ...htmlProps, className: cx(popover, htmlProps.className) };
}
github reakit / reakit / packages / reakit-system-bootstrap / src / Tab.ts View on Github external
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) };
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};
    color: ${color};
    z-index: 999;

    &:focus {
      box-shadow: 0 0 0 0.2em ${boxShadowColor};