Skip to content

Commit

Permalink
Override default theme in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
efoken committed Dec 23, 2024
1 parent 38befa5 commit caa64c0
Show file tree
Hide file tree
Showing 34 changed files with 237 additions and 381 deletions.
24 changes: 4 additions & 20 deletions docs/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { createTheme } from '@react-universal/core';
import { AppRouterProdivder } from '@react-universal/next';
import type { Metadata } from 'next';
import { Inter } from 'next/font/google';
import { font, theme } from './theme';
import './globals.css';
import { AppRouterProdivder } from '@react-universal/next';

const inter = Inter({ subsets: ['latin'] });

export const metadata: Metadata = {
title: 'Create Next App',
Expand All @@ -18,21 +15,8 @@ export default function RootLayout({
}>) {
return (
<html suppressHydrationWarning lang="en">
<body className={inter.className}>
<AppRouterProdivder
theme={createTheme({
fonts: {
body: {
family: inter.style.fontFamily,
} as any,
heading: {
family: inter.style.fontFamily,
} as any,
},
})}
>
{children}
</AppRouterProdivder>
<body className={font.className}>
<AppRouterProdivder theme={theme}>{children}</AppRouterProdivder>
</body>
</html>
);
Expand Down
53 changes: 53 additions & 0 deletions docs/app/theme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { createTheme } from '@react-universal/core';
import type { ThemeColor } from '@react-universal/core';
import { Inter } from 'next/font/google';

export const font = Inter({ subsets: ['latin'] });

export const theme = createTheme({
colors: {
black: '#09090b',
white: '#ffffff',
background: {
default: { _light: '#fff', _dark: '#000' },
muted: { _light: '#f4f4f5', _dark: '#18181b' },
},
text: {
default: { _light: '#09090b', _dark: '#fafafa' },
muted: { _light: '#52525b', _dark: '#a1a1aa' },
},
border: {
default: { _light: '#e4e4e7', _dark: '#27272a' },
muted: { _light: '#f4f4f5', _dark: '#18181b' },
},
},
fonts: {
body: {
family: font.style.fontFamily,
},
heading: {
family: font.style.fontFamily,
},
},
});

declare module '@react-universal/core' {
export interface Theme {
colors: {
black: ThemeColor;
white: ThemeColor;
background: {
default: ThemeColor;
muted: ThemeColor;
};
text: {
default: ThemeColor;
muted: ThemeColor;
};
border: {
default: ThemeColor;
muted: ThemeColor;
};
};
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"format": "biome format --write . && prettier --log-level error --write \"**/*.{md,mdx,yml}\"",
"lint": "biome lint .",
"postinstall": "manypkg check",
"storybook": "yarn workspace @react-universal/vite-plugin build && sb dev",
"storybook": "yarn workspace @react-universal/vite-plugin dev && sb dev",
"test": "vitest",
"typecheck": "yarn tsc && yarn workspaces foreach -Apt run typecheck"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/Button/Button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export const Default: Story = {
args: {
children: <Text>Button</Text>,
sx: {
bgColor: '#ddd',
borderRadius: '1',
bgColor: 'background.muted',
borderRadius: 2,
p: 1,
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/Heading/Heading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const HeadingRoot = styled(Text, {
}));

export const Heading = forwardRef<HTMLHeadingElement & HeadingMethods, HeadingProps>(
(props, ref) => <HeadingRoot ref={ref} aria-level={2} role="heading" {...props} />,
(props: HeadingProps, ref) => <HeadingRoot ref={ref} aria-level={2} role="heading" {...props} />,
) as HeadingType;

Heading.displayName = 'Heading';
4 changes: 2 additions & 2 deletions packages/components/src/Image/Image.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use client';

import {
type ForwardedProps,
forwardedProps,
getLocaleDirection,
styled,
useElementLayout,
usePlatformMethods,
type ForwardedProps,
} from '@react-universal/core';
import type { AnyObject } from '@react-universal/utils';
import { noop, pick } from '@react-universal/utils';
Expand Down Expand Up @@ -49,7 +49,7 @@ const ImageRoot = styled('img', {
});

export const Image = forwardRef<HTMLImageElement & ImageMethods, ImageProps>(
({ dir, onError, onLayout, onLoad, onProgress, onPartialLoad, ...props }, ref) => {
({ dir, onError, onLayout, onLoad, onProgress, onPartialLoad, ...props }: ImageProps, ref) => {
const hostRef = useRef<HTMLImageElement>(null);

useElementLayout(hostRef, onLayout);
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/Link/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const LinkRoot = styled(Text, {
})();

export const Link = forwardRef<HTMLAnchorElement & TextMethods, LinkProps>(
({ download, rel, target, ...props }, ref) => (
({ download, rel, target, ...props }: LinkProps, ref) => (
<LinkRoot
ref={ref}
hrefAttrs={{
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/Modal/Modal.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const Modal = forwardRef<any, ModalProps>(
role,
style,
...props
},
}: ModalProps,
ref,
) => {
const handleAccessibilityEscape = () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const Modal = forwardRef<HTMLDialogElement & ModalMethods, ModalProps>(
open,
role,
...props
},
}: ModalProps,
ref,
) => {
const hostRef = useRef<HTMLDialogElement>(null);
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/Popover/Popover.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const Popover = forwardRef<any, PopoverProps>(
strategy: _strategy,
style,
...props
},
}: PopoverProps,
ref,
) => {
const hostRef = useRef<RNView>(null);
Expand Down
7 changes: 6 additions & 1 deletion packages/components/src/Popover/Popover.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ export const Default: Story = {

return (
<>
<Button aria-describedby={id} type="button" onPress={handlePress}>
<Button
aria-describedby={id}
type="button"
sx={{ bgColor: 'background.muted', borderRadius: 2, p: 1 }}
onPress={handlePress}
>
<Text>Toggle Popup</Text>
</Button>
<Popover {...args} anchor={anchor} id={id} open={open} />
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/Popover/Popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const Popover = forwardRef<HTMLDivElement & PopoverMethods, PopoverProps>
role = 'tooltip',
strategy: _strategy = 'absolute',
...props
},
}: PopoverProps,
ref,
) => {
const hostRef = useRef<HTMLDivElement>(null);
Expand Down
136 changes: 0 additions & 136 deletions packages/components/src/PressAwayListener/PressAwayListener.tsx

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion packages/components/src/ScrollView/ScrollView.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const ScrollView = forwardRef<any, ScrollViewProps>(
role,
style,
...props
},
}: ScrollViewProps,
ref,
) => (
<ScrollViewRoot
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/ScrollView/ScrollView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export const ScrollView = forwardRef<HTMLElement & ScrollViewMethods, ScrollView
stickyHeaderIndices,
style,
...props
},
}: ScrollViewProps,
ref,
) => {
const scrollNodeRef = useRef<React.ElementRef<typeof View>>();
Expand Down
Loading

0 comments on commit caa64c0

Please sign in to comment.