mirror of
https://github.com/outline/outline.git
synced 2026-11-20 21:23:06 +03:00
* React 19 upgrade Bumps react and react-dom to 19.2.8, with the dependency changes React 19 requires: react-is 19, @types/react 19, @types/react-dom 19, react-helmet-async 3 and react-avatar-editor 15 (which now ships its own types). framer-motion moves to 13 — its v6 types reference React.ReactHTML, removed from @types/react 19. The type changes fall into a few classes: - The global JSX namespace is gone, so JSX.Element becomes React.JSX.Element and the custom element declarations move into a module augmentation. - useRef() now requires an initial value. - A ref created with a null initial value is typed nullable, so consumers that accept one are widened to RefObject<T | null>. - React.ReactChild was removed; tooltips take React.ReactNode. - Ref callbacks may only return a cleanup function. react-dnd connectors return the connected node, so useDragRef and useDropRef wrap useDrag and useDrop and hand back a ref callback. react-i18next stays on v12: i18next 23 drops compatibilityJSON "v3", which would rewrite all 64 _plural keys across every locale. outline-icons, oy-vey and react-waypoint have no release that lists React 19 as a peer. All three render correctly under it; the install reports them as unmet peers. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * Remove react-helmet and forwardRef --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
73 lines
1.7 KiB
TypeScript
73 lines
1.7 KiB
TypeScript
import * as React from "react";
|
|
import styled, { css } from "styled-components";
|
|
import NudeButton from "./NudeButton";
|
|
import { hover, s } from "@shared/styles";
|
|
|
|
type Props = React.HTMLAttributes<HTMLButtonElement> & {
|
|
/** The current color value in hex format. If no color is passed a radial gradient will be shown */
|
|
color?: string;
|
|
/** Whether the button is currently active/selected */
|
|
active?: boolean;
|
|
/** The size of the button in pixels */
|
|
size?: number;
|
|
ref?: React.Ref<HTMLButtonElement>;
|
|
};
|
|
|
|
export function ColorButton({
|
|
color,
|
|
active = false,
|
|
size = 24,
|
|
ref,
|
|
...rest
|
|
}: Props) {
|
|
return (
|
|
<ColorButtonInternal
|
|
$active={active}
|
|
$size={size}
|
|
{...rest}
|
|
style={{ "--color": color, ...rest.style } as React.CSSProperties}
|
|
ref={ref}
|
|
>
|
|
<Selected />
|
|
</ColorButtonInternal>
|
|
);
|
|
}
|
|
|
|
/** Highlight for the hovered or selected swatch, falls back for the gradient. */
|
|
const ring = css`2px solid var(--color, ${s("textTertiary")})`;
|
|
|
|
const Selected = styled.span`
|
|
width: 10px;
|
|
height: 5px;
|
|
border-left: 2px solid white;
|
|
border-bottom: 2px solid white;
|
|
transform: translateY(-25%) rotate(-45deg);
|
|
`;
|
|
|
|
const ColorButtonInternal = styled(NudeButton)<{
|
|
$active: boolean;
|
|
$size: number;
|
|
}>`
|
|
display: inline-flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
width: ${({ $size }) => $size}px;
|
|
height: ${({ $size }) => $size}px;
|
|
border-radius: 50%;
|
|
background: var(
|
|
--color,
|
|
linear-gradient(135deg, #ff5858 0%, #fbcc34 50%, #00c6ff 100%)
|
|
);
|
|
|
|
outline-offset: 1px;
|
|
outline: ${({ $active }) => ($active ? ring : "none")};
|
|
|
|
&: ${hover} {
|
|
outline: ${ring} !important;
|
|
}
|
|
|
|
& ${Selected} {
|
|
display: ${({ $active }) => ($active ? "block" : "none")};
|
|
}
|
|
`;
|