/* Copyright (c) Uber Technologies, Inc. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. */ import * as React from "react"; import { useValueDebounce } from "react-view"; import { Input, SIZE } from "baseui/input"; import { useStyletron } from "baseui"; import Link from "next/link"; import { StyledLink } from "baseui/link"; import { ParagraphXSmall } from "baseui/typography"; import { getActiveTheme, getThemeDiff } from "./provider"; type ThemeEditorProps = { componentName: string; theme: { [key: string]: string }; themeInit: { [key: string]: string }; set: (value: { [key: string]: string } | undefined) => void; }; type ColumnProps = { themeKeys: string[]; theme: { [key: string]: string }; themeInit: { [key: string]: string }; set: (value: { [key: string]: string } | undefined) => void; }; const ColorInput: React.FC<{ themeKey: string; themeInit: { [key: string]: string }; globalColor: string; globalSet: (color: string) => void; }> = ({ themeKey, themeInit, globalSet, globalColor }) => { const [css, $theme] = useStyletron(); const [color, setColor] = useValueDebounce(globalColor, globalSet); return ( ); }; const Column: React.FC = ({ themeKeys, themeInit, theme, set, }) => { const [css] = useStyletron(); return (
{themeKeys.map((key) => { return ( { const diff = getThemeDiff( { ...theme, [key]: color, }, themeInit, ); set(Object.keys(diff).length > 0 ? diff : undefined); }} themeInit={themeInit} /> ); })}
); }; const ThemeEditor: React.FC = ({ theme, themeInit, set, componentName, }) => { const [css, currentTheme] = useStyletron(); const activeTheme = getActiveTheme(theme, themeInit); const themeKeys = Object.keys(activeTheme); const midPoint = themeKeys.length % 2 === 0 ? themeKeys.length / 2 : themeKeys.length / 2 + 1; const firstThemeKeys = themeKeys.slice(0, midPoint); const secondThemeKeys = themeKeys.slice(midPoint); return ( Do you want to change {componentName} colors globally? You can customize the theme through ThemeProvider and set your own colors.{" "} Learn more . Try different values:
); }; export default ThemeEditor;