Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Setup docs v2 #28

Merged
merged 6 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,18 @@
<link rel="icon" href="%sveltekit.assets%/logo-square.svg" sizes="any" type="image/svg+xml" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Chakra UI Svelte</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500&display=swap"
rel="stylesheet"
/>
%sveltekit.head%
<style>
* {
font-family: Poppins, sans-serif;
}
</style>
</head>
<body>
<div>%sveltekit.body%</div>
Expand Down
36 changes: 36 additions & 0 deletions src/docs/components/ActionButton.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<script>
import { current_component } from 'svelte/internal';
import { Button, Icon, Link, VisuallyHidden } from '$lib/components';
import { eventsForward } from '$lib/core';

import { hoverBg, color } from '../../stores';

export let icon = '';
export let label = '';
export let href = '';
export let target = '_blank';
export let rel = 'button';
const SocialIcon = icon || 'span';
const events = eventsForward(current_component);
</script>

<Link {href} {target} {rel}>
<Button
sx={{
bg: 'transparent',
'&:hover': {
bg: $hoverBg
}
}}
size="xs"
display="flex"
justifyContent="center"
alignItems="center"
title={label}
{events}
>
<VisuallyHidden>{label}</VisuallyHidden>
<Icon as={SocialIcon} wrap="div" w="4" h="4" color={$color} />
<slot />
</Button>
</Link>
14 changes: 0 additions & 14 deletions src/docs/components/SocialButton.svelte

This file was deleted.

40 changes: 22 additions & 18 deletions src/docs/layout/Footer.svelte
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
<script>
import { Box, Stack, Text } from '$lib/components';
import { colorModeValue } from '$lib/stores';

import SocialButton from '../components/SocialButton.svelte';
import { Box, Stack, Text, Link } from '$lib/components';
import FaTwitter from 'svelte-icons/fa/FaTwitter.svelte';
import FaGithub from 'svelte-icons/fa/FaGithub.svelte';
import FaLinkedin from 'svelte-icons/fa/FaLinkedin.svelte';
import FaEmail from 'svelte-icons/fa/FaEnvelope.svelte';

const bg = colorModeValue('gray.50', 'gray.900');
const color = colorModeValue('gray.700', 'gray.200');
import { bg, color } from '../../stores';
import ActionButton from '../components/ActionButton.svelte';
</script>

<Box bg={$bg} color={$color}>
<Stack
py={4}
orientation="horizontal"
spacing={4}
justifyContent={{ base: 'center', md: 'space-between' }}
alignItems={{ base: 'center', md: 'center' }}
flexDirection="column"
justifyContent="center"
alignItems="center"
fontSize="sm"
>
<Text>© 2022 Chakra UI. All rights reserved</Text>
<Stack
orientation="horizontal"
spacing={6}
justifyContent={{ base: 'center', md: 'space-between' }}
sx={{ fontSize: 'sm' }}
>
<SocialButton label="Twitter" icon={FaTwitter} href="#" />
<SocialButton label="YouTube" icon={FaGithub} href="#" />
<Text>
Proudly developed by
<Link href="https://elcharitas.dev" target="_blank">Jonathan Irhodia</Link>
</Text>
<Stack>
<ActionButton label="Follow on Github" icon={FaGithub} href="https://github.com" />
<ActionButton label="Follow on Twitter" icon={FaTwitter} />
<ActionButton label="Connect on Linkedin" icon={FaLinkedin} />
<ActionButton
label="Send me an Email"
icon={FaEmail}
href="mailto:[email protected]"
/>
</Stack>
</Stack>
</Box>
71 changes: 65 additions & 6 deletions src/docs/layout/Navbar.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,71 @@
<script>
import { Box, Flex, Stack, Text, Button, IconButton, Logo } from '$lib/components';
import { colorModeValue } from '$lib/stores';
import { Box, Flex, Stack, ButtonGroup, Input, Logo } from '$lib/components';
import { colorMode } from '$lib/stores';

import FaTwitter from 'svelte-icons/fa/FaTwitter.svelte';
import FaGithub from 'svelte-icons/fa/FaGithub.svelte';
import FaSun from 'svelte-icons/fa/FaSun.svelte';
import FaMoon from 'svelte-icons/fa/FaMoon.svelte';

import { bg, inputBg, color } from '../../stores';
import ActionButton from '../components/ActionButton.svelte';
</script>

<Box>
<Stack flex={{ base: 1, md: 0 }} justify={'flex-end'} direction={'row'} spacing={6}>
<Box
as="nav"
h="16"
bg={$bg}
shadow="md"
display="flex"
alignItems="center"
justifyContent="space-around"
>
<Stack direction="row" spacing={6}>
<Logo />
<Button fontSize={'sm'} fontWeight={400} bgColor="green.500">Sign In</Button>
<Button fontSize={'sm'} fontWeight={400}>Sign In</Button>
</Stack>

<Flex justify="center" justifyContent="center" display={{ base: 'none', md: 'flex' }} />

<Flex justify="right" justifyContent="end">
<Input
placeholder="Search the docs."
sx={{
bg: $inputBg,
color: $color,
width: '300px',
fontWeight: 400,
fontSize: 'sm',
_hover: {
bg: $inputBg
},
_placeholder: {
color: 'gray.400'
}
}}
mr="8"
display={{ base: 'none', md: 'inline' }}
/>
<ButtonGroup alignItems="center" justifyContent="space-between">
<ActionButton
label="Star the Github Repo"
icon={FaGithub}
href="https://github.com"
display={{ base: 'none', md: 'inline' }}
/>
<ActionButton label="Twitter" icon={FaTwitter} display={{ base: 'none', md: 'inline' }} />
{#if $colorMode === 'dark'}
<ActionButton
icon={FaSun}
label="Switch to light Mode"
on:click={() => colorMode.set('light')}
/>
{:else}
<ActionButton
icon={FaMoon}
label="Switch to dark Mode"
on:click={() => colorMode.set('dark')}
/>
{/if}
</ButtonGroup>
</Flex>
</Box>
11 changes: 11 additions & 0 deletions src/lib/components/buttons/ButtonGroup.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script lang="ts">
import { current_component } from 'svelte/internal';
import { eventsForward } from '$lib/core';
import Stack from '../stacks/Stack.svelte';

const events = eventsForward(current_component);
</script>

<Stack {events} {...$$props}>
<slot />
</Stack>
4 changes: 2 additions & 2 deletions src/lib/components/buttons/IconButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import Button from './Button.svelte';
import Icon from '$lib/components/basic/Icon.svelte';

export let icon;
export let wrap = "div";
export let icon: string;
export let wrap = 'div';
const events = eventsForward(current_component);
</script>

Expand Down
2 changes: 2 additions & 0 deletions src/lib/components/buttons/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export { default as Button } from './Button.svelte';
export { default as IconButton } from './IconButton.svelte';
export { default as ButtonGroup } from './ButtonGroup.svelte';
export { default as RippleButton } from './RippleButton.svelte';
2 changes: 1 addition & 1 deletion src/lib/stores/colormode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const isDarkMode = derived(colorMode, (colorMode) => colorMode === 'dark'
* @param dark
* @returns
*/
export const colorModeValue = (light: unknown, dark: unknown) => {
export const colorModeValue = <T extends unknown>(light: T, dark: T) => {
const store = createStore(() => light);
colorMode.subscribe((val) => {
store.set(val === 'light' ? light : dark);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/utils/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function createStore<T>(

return {
initial,
get: get.bind({}, store),
get: get.bind({}, store) as T,
...store
};
}
17 changes: 11 additions & 6 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<script lang="ts">
import { ChakraProvider } from '$lib/components';
import { ThemeProvider, Box, Container } from '$lib/components';
import Navbar from '$docs/layout/Navbar.svelte';
import Footer from '$docs/layout/Footer.svelte';
import { bg, color } from '../stores';
</script>

<ChakraProvider>
<Navbar />
<slot />
<Footer />
</ChakraProvider>
<ThemeProvider>
<Box bg={$bg} color={$color} minH="100vh">
<Navbar />
<Container>
<slot />
</Container>
<Footer />
</Box>
</ThemeProvider>
6 changes: 6 additions & 0 deletions src/stores.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { colorModeValue } from '$lib/stores/colormode';

export const color = colorModeValue('gray.600', 'gray.300');
export const hoverBg = colorModeValue('gray.60', 'gray.700');
export const bg = colorModeValue('gray.50', 'gray.800');
export const inputBg = colorModeValue('gray.200', 'gray.600');