diff --git a/examples/nextjs/pages/index.tsx b/examples/nextjs/pages/index.tsx index e892c6300..4391e9676 100644 --- a/examples/nextjs/pages/index.tsx +++ b/examples/nextjs/pages/index.tsx @@ -4,7 +4,7 @@ import '@skip-go/widget/style.css'; const Home: NextPage = () => { return ( -
+
{ }} />
+ +
+ +
); }; diff --git a/packages/widget/src/ui/AssetInput.tsx b/packages/widget/src/ui/AssetInput.tsx index 47fa37c67..6f2aeecf9 100644 --- a/packages/widget/src/ui/AssetInput.tsx +++ b/packages/widget/src/ui/AssetInput.tsx @@ -21,6 +21,7 @@ import { import { formatPercent, formatUSD } from '../utils/intl'; import { useSwapWidgetUIStore } from '../store/swap-widget'; import { css } from '@emotion/css'; +import { styled } from 'styled-components'; interface Props { amount: string; @@ -120,7 +121,7 @@ function AssetInput({ /> )} - props.theme.primary.backgroundColor}; + color: ${(props) => props.theme.primary.textColor}; +`; diff --git a/packages/widget/src/ui/AssetSelect/index.tsx b/packages/widget/src/ui/AssetSelect/index.tsx index b6f2a0eef..da2aa3358 100644 --- a/packages/widget/src/ui/AssetSelect/index.tsx +++ b/packages/widget/src/ui/AssetSelect/index.tsx @@ -7,6 +7,7 @@ import { cn } from '../../utils/ui'; import { Dialog } from '../Dialog/Dialog'; import { DialogTrigger } from '../Dialog/DialogTrigger'; import { DialogContent } from '../Dialog/DialogContent'; +import { styled } from 'styled-components'; interface Props { asset?: Asset; @@ -29,7 +30,7 @@ function AssetSelect({ return ( -
- + props.theme.secondary.backgroundColor}; + color: ${(props) => props.theme.secondary.textColor}; +`; diff --git a/packages/widget/src/ui/ChainSelect/ChainSelectTrigger.tsx b/packages/widget/src/ui/ChainSelect/ChainSelectTrigger.tsx index ac8c82723..d26f9ab64 100644 --- a/packages/widget/src/ui/ChainSelect/ChainSelectTrigger.tsx +++ b/packages/widget/src/ui/ChainSelect/ChainSelectTrigger.tsx @@ -2,6 +2,7 @@ import { ChevronDownIcon } from '@heroicons/react/20/solid'; import { forwardRef } from 'react'; import { Chain } from '../../hooks/use-chains'; import { cn } from '../../utils/ui'; +import { styled } from 'styled-components'; interface Props { chain?: Chain; @@ -10,7 +11,7 @@ interface Props { const ChainSelectTrigger = forwardRef( function ChainSelectTrigger({ chain, ...props }, ref) { return ( - + ); } // ); export default ChainSelectTrigger; + +const ChainSelectButton = styled.button` + background-color: ${(props) => props.theme.secondary.backgroundColor}; + color: ${(props) => props.theme.secondary.textColor}; +`; diff --git a/packages/widget/src/ui/Widget.tsx b/packages/widget/src/ui/Widget.tsx index 5ef07be95..0123fe88a 100644 --- a/packages/widget/src/ui/Widget.tsx +++ b/packages/widget/src/ui/Widget.tsx @@ -26,12 +26,17 @@ import { useSwapWidgetUIStore } from '../store/swap-widget'; import { css } from '@emotion/css'; import { CraftedBySkip } from './CraftedBySkip'; import { ThemeProvider, styled } from 'styled-components'; -import { defaultTheme } from './theme'; +import { Theme, defaultTheme } from './theme'; + +type SwapWidgetProps = React.HTMLAttributes & { + theme?: Theme; +}; export const SwapWidgetUI = ({ className, + theme, ...divProps -}: React.HTMLAttributes) => { +}: SwapWidgetProps) => { useEffect(() => void disclosure.rehydrate(), []); const { openWalletModal } = useWalletModal(); @@ -91,7 +96,7 @@ export const SwapWidgetUI = ({ const accountStateKey = `${srcAccount?.isWalletConnected ? 'src' : 'no-src'}`; return ( - + , 'className' | 'style'>, - ConfigureSwapWidgetArgs {} +export type SwapWidgetProps = Pick< + React.HTMLAttributes, + 'className' | 'style' +> & + ConfigureSwapWidgetArgs & { + theme?: Theme; + }; export const SwapWidget: React.FC = ({ colors, @@ -18,6 +23,7 @@ export const SwapWidget: React.FC = ({ onlyTestnet, defaultRoute, routeConfig, + theme, }) => { useEffect(() => { configureSwapWidget({ @@ -30,5 +36,5 @@ export const SwapWidget: React.FC = ({ }, [colors, onlyTestnet, settings, defaultRoute, routeConfig]); const divProps = { className, style }; - return ; + return ; }; diff --git a/packages/widget/src/ui/theme.ts b/packages/widget/src/ui/theme.ts index c63d235c2..586c212ea 100644 --- a/packages/widget/src/ui/theme.ts +++ b/packages/widget/src/ui/theme.ts @@ -2,24 +2,26 @@ import 'styled-components'; export const defaultTheme = { primary: { - backgroundColor: 'yellow', - textColor: 'blue', + backgroundColor: 'white', + textColor: 'black', }, secondary: { - backgroundColor: '', - textColor: '', + backgroundColor: 'rgb(245, 245, 245)', + textColor: 'black', }, }; +export type Theme = { + primary: { + backgroundColor: string; + textColor: string; + }; + secondary: { + backgroundColor: string; + textColor: string; + }; +}; + declare module 'styled-components' { - export interface DefaultTheme { - primary: { - backgroundColor: string; - textColor: string; - }; - secondary: { - backgroundColor: string; - textColor: string; - }; - } + export interface DefaultTheme extends Theme {} }