Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit d30eac7

Browse files
committed
feat(website): add navbar to layouts
1 parent 230e7b7 commit d30eac7

File tree

9 files changed

+379
-124
lines changed

9 files changed

+379
-124
lines changed

website-new/components/ChakraLogo.vue

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<script setup lang="ts">
2+
import { chakra, useColorModeValue } from "@chakra-ui/vue-next"
3+
4+
const fill = useColorModeValue("#2D3748", "#fff")
5+
// todo: AppHeader causes re-rendering of this logo, why?
6+
// console.log({ fill })
7+
</script>
8+
9+
<template>
10+
<!-- eslint-disable -->
11+
<chakra.svg
12+
width="auto"
13+
height="8"
14+
viewBox="0 0 617 181"
15+
xmlns="http://www.w3.org/2000/svg"
16+
style="
17+
fill-rule: evenodd;
18+
clip-rule: evenodd;
19+
stroke-linejoin: round;
20+
stroke-miterlimit: 2;
21+
"
22+
>
23+
<path
24+
d="M580.425,139.8c-4.32,0 -8.205,-0.777 -11.652,-2.331c-3.448,-1.553 -6.17,-3.854 -8.168,-6.902c-1.997,-3.048 -2.996,-6.806 -2.996,-11.275c0,-3.847 0.71,-7.028 2.131,-9.544c1.42,-2.515 3.358,-4.527 5.815,-6.037c2.456,-1.509 5.23,-2.656 8.323,-3.44c3.092,-0.784 6.296,-1.354 9.61,-1.709c3.995,-0.414 7.235,-0.791 9.721,-1.132c2.486,-0.34 4.299,-0.873 5.438,-1.598c1.139,-0.725 1.709,-1.857 1.709,-3.395l0,-0.267c0,-3.344 -0.992,-5.933 -2.974,-7.768c-1.983,-1.835 -4.839,-2.752 -8.567,-2.752c-3.936,0 -7.051,0.858 -9.344,2.575c-2.294,1.716 -3.84,3.743 -4.639,6.081l-15.004,-2.131c1.184,-4.143 3.137,-7.613 5.86,-10.409c2.722,-2.797 6.052,-4.898 9.987,-6.303c3.936,-1.406 8.286,-2.109 13.051,-2.109c3.285,0 6.555,0.385 9.81,1.154c3.255,0.77 6.229,2.035 8.922,3.796c2.693,1.76 4.861,4.15 6.503,7.168c1.643,3.019 2.464,6.792 2.464,11.32l0,45.632l-15.448,0l0,-9.366l-0.532,0c-0.977,1.894 -2.346,3.662 -4.106,5.304c-1.761,1.643 -3.966,2.959 -6.614,3.951c-2.649,0.991 -5.749,1.487 -9.3,1.487Zm-183.729,0c-4.32,0 -8.204,-0.777 -11.652,-2.331c-3.447,-1.553 -6.17,-3.854 -8.167,-6.902c-1.998,-3.048 -2.997,-6.806 -2.997,-11.275c0,-3.847 0.711,-7.028 2.131,-9.544c1.42,-2.515 3.359,-4.527 5.815,-6.037c2.456,-1.509 5.231,-2.656 8.323,-3.44c3.092,-0.784 6.296,-1.354 9.61,-1.709c3.995,-0.414 7.236,-0.791 9.721,-1.132c2.486,-0.34 4.299,-0.873 5.438,-1.598c1.139,-0.725 1.709,-1.857 1.709,-3.395l0,-0.267c0,-3.344 -0.991,-5.933 -2.974,-7.768c-1.983,-1.835 -4.838,-2.752 -8.567,-2.752c-3.936,0 -7.051,0.858 -9.344,2.575c-2.293,1.716 -3.84,3.743 -4.639,6.081l-15.003,-2.131c1.184,-4.143 3.137,-7.613 5.859,-10.409c2.723,-2.797 6.052,-4.898 9.988,-6.303c3.936,-1.406 8.286,-2.109 13.05,-2.109c3.285,0 6.555,0.385 9.81,1.154c3.255,0.77 6.229,2.035 8.922,3.796c2.693,1.76 4.861,4.15 6.503,7.168c1.643,3.019 2.464,6.792 2.464,11.32l0,45.632l-15.447,0l0,-9.366l-0.533,0c-0.977,1.894 -2.345,3.662 -4.106,5.304c-1.761,1.643 -3.966,2.959 -6.614,3.951c-2.649,0.991 -5.748,1.487 -9.3,1.487Zm-133.671,-0.045c-6.807,0 -12.644,-1.494 -17.512,-4.483c-4.868,-2.989 -8.612,-7.124 -11.231,-12.407c-2.618,-5.282 -3.928,-11.371 -3.928,-18.266c0,-6.925 1.332,-13.043 3.995,-18.355c2.663,-5.312 6.429,-9.455 11.297,-12.429c4.868,-2.974 10.631,-4.461 17.29,-4.461c5.534,0 10.439,1.014 14.715,3.041c4.276,2.027 7.686,4.883 10.231,8.567c2.545,3.684 3.995,7.983 4.351,12.895l-15.359,0c-0.622,-3.285 -2.094,-6.03 -4.417,-8.234c-2.323,-2.205 -5.423,-3.307 -9.299,-3.307c-3.285,0 -6.17,0.88 -8.656,2.641c-2.486,1.761 -4.417,4.284 -5.793,7.568c-1.376,3.285 -2.064,7.221 -2.064,11.808c0,4.646 0.681,8.634 2.042,11.963c1.361,3.329 3.277,5.889 5.748,7.679c2.471,1.79 5.379,2.686 8.723,2.686c2.367,0 4.49,-0.452 6.37,-1.354c1.879,-0.903 3.454,-2.212 4.727,-3.929c1.272,-1.716 2.145,-3.802 2.619,-6.259l15.359,0c-0.385,4.824 -1.806,9.093 -4.262,12.807c-2.456,3.714 -5.8,6.614 -10.032,8.7c-4.231,2.086 -9.203,3.129 -14.914,3.129Zm251.985,-1.331l0,-68.182l15.58,0l0,11.364l0.71,0c1.243,-3.936 3.381,-6.977 6.415,-9.122c3.033,-2.146 6.503,-3.219 10.409,-3.219c0.888,0 1.886,0.037 2.996,0.111c1.11,0.074 2.035,0.185 2.775,0.333l0,14.782c-0.681,-0.237 -1.754,-0.451 -3.219,-0.644c-1.465,-0.192 -2.878,-0.288 -4.239,-0.288c-2.93,0 -5.556,0.629 -7.879,1.886c-2.323,1.258 -4.15,2.997 -5.482,5.216c-1.332,2.219 -1.998,4.779 -1.998,7.679l0,40.084l-16.068,0Zm-195.981,-39.951l0,39.951l-16.068,0l0,-97.882l15.713,0l0,41.286l0.799,0c1.598,-3.848 4.077,-6.888 7.436,-9.122c3.358,-2.235 7.642,-3.352 12.85,-3.352c4.735,0 8.863,0.992 12.385,2.974c3.521,1.983 6.251,4.883 8.19,8.701c1.938,3.817 2.907,8.478 2.907,13.982l0,43.413l-16.069,0l0,-40.927c0,-4.587 -1.176,-8.16 -3.529,-10.72c-2.352,-2.56 -5.645,-3.84 -9.876,-3.84c-2.841,0 -5.379,0.614 -7.613,1.842c-2.234,1.228 -3.98,2.997 -5.238,5.305c-1.258,2.308 -1.887,5.105 -1.887,8.389Zm143.438,-0.843l1.11,0l24.503,-27.388l18.776,0l-26.433,29.431l27.987,38.751l-19.221,0l-20.876,-29.185l-5.846,6.267l0,22.918l-16.069,0l0,-97.878l16.069,-0.004l0,57.088Zm122.131,30.362c3.225,0 6.022,-0.643 8.389,-1.931c2.368,-1.287 4.195,-2.996 5.482,-5.127c1.288,-2.13 1.931,-4.453 1.931,-6.969l0,-8.034c-0.503,0.414 -1.354,0.799 -2.552,1.154c-1.199,0.355 -2.538,0.666 -4.017,0.932c-1.48,0.266 -2.945,0.503 -4.395,0.71c-1.45,0.208 -2.708,0.385 -3.773,0.533c-2.397,0.326 -4.542,0.858 -6.436,1.598c-1.894,0.74 -3.389,1.768 -4.484,3.085c-1.095,1.317 -1.642,3.011 -1.642,5.083c0,2.959 1.08,5.193 3.24,6.702c2.161,1.51 4.913,2.264 8.257,2.264Zm-183.729,0c3.226,0 6.022,-0.643 8.39,-1.931c2.367,-1.287 4.194,-2.996 5.482,-5.127c1.287,-2.13 1.931,-4.453 1.931,-6.969l0,-8.034c-0.504,0.414 -1.354,0.799 -2.553,1.154c-1.198,0.355 -2.537,0.666 -4.017,0.932c-1.48,0.266 -2.945,0.503 -4.395,0.71c-1.45,0.208 -2.707,0.385 -3.773,0.533c-2.397,0.326 -4.542,0.858 -6.436,1.598c-1.894,0.74 -3.389,1.768 -4.483,3.085c-1.095,1.317 -1.643,3.011 -1.643,5.083c0,2.959 1.08,5.193 3.241,6.702c2.16,1.51 4.912,2.264 8.256,2.264Z"
25+
:fill="fill"
26+
/>
27+
<path
28+
d="M90.354,0.171c-49.372,0 -90,40.628 -90,90c0,49.373 40.628,90 90,90c49.373,0 90,-40.627 90,-90c0,-49.372 -40.627,-90 -90,-90Zm-28.2,144.167l24.417,-45l-28.209,0.541l54.684,-63.825l-23.625,46.617l33.208,-1.542l-60.475,63.209Z"
29+
style="fill: url(#_Linear1)"
30+
/>
31+
<defs>
32+
<linearGradient
33+
id="_Linear1"
34+
x1="0"
35+
y1="0"
36+
x2="1"
37+
y2="0"
38+
gradientUnits="userSpaceOnUse"
39+
gradientTransform="matrix(180,-0.741309,0.741309,180,0.354053,90.2243)"
40+
>
41+
<stop offset="0" style="stop-color: #41b883; stop-opacity: 1" />
42+
<stop offset="1" style="stop-color: #78ffbe; stop-opacity: 1" />
43+
</linearGradient>
44+
</defs>
45+
</chakra.svg>
46+
</template>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<script setup lang="ts">
2+
import { CBox, CIcon } from "@chakra-ui/vue-next"
3+
import siteConfig from "@/config/site-config"
4+
</script>
5+
6+
<template>
7+
<CBox
8+
:display="{ base: 'none', lg: 'flex' }"
9+
alignItems="center"
10+
as="a"
11+
aria-label="Sponsor Chakra UI on Open Collective"
12+
:href="siteConfig.openCollective.url"
13+
target="_blank"
14+
rel="noopener noreferrer"
15+
bg="gray.50"
16+
borderWidth="1px"
17+
borderColor="gray.200"
18+
px="1em"
19+
minH="36px"
20+
borderRadius="md"
21+
fontSize="sm"
22+
color="gray.800"
23+
outline="0"
24+
transition="all 0.3s"
25+
:_hover="{
26+
bg: 'gray.100',
27+
borderColor: 'gray.300',
28+
}"
29+
:_active="{
30+
borderColor: 'gray.200',
31+
}"
32+
:_focus="{
33+
boxShadow: 'outline',
34+
}"
35+
v-bind="$attrs"
36+
>
37+
<CIcon name="heart" w="4" h="4" color="red.500" mr="2" />
38+
<CBox as="strong" lineHeight="inherit" fontWeight="semibold">
39+
Sponsor
40+
</CBox>
41+
</CBox>
42+
</template>

website-new/components/TheNavbar.vue

Lines changed: 142 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,112 +1,151 @@
1-
<template>
2-
<chakra.nav
3-
h="60px"
4-
w="100%"
5-
:px="[4, 10, 12]"
6-
d="flex"
7-
position="fixed"
8-
align-items="center"
9-
shadow="sm"
10-
bg="white"
11-
z-index="10"
12-
border-top="6px solid"
13-
border-color="emerald.500"
14-
>
15-
<CFlex align-items="center" justify-content="flex-start" flex="1">
16-
<chakra.a
17-
aria-current="page"
18-
aria-label="Chakra UI Vue, Back to homepage"
19-
href="/"
20-
h="auto"
21-
d="flex"
22-
flex-direction="row"
23-
align-items="center"
24-
>
25-
<CBox w="30px" mr="2"><ChakraUILogoIcon /></CBox>
26-
<chakra.h1
27-
font-size="xl"
28-
font-family="heading"
29-
line-height="1.2"
30-
letter-spacing="tighter"
31-
:d="{ base: 'none', md: 'block' }"
32-
>
33-
chakra-ui/vue-next
34-
<CBadge
35-
font-family="mono"
36-
font-size="0.5em"
37-
text-transform="lowercase"
38-
>{{ pkg.version }}</CBadge
39-
>
40-
</chakra.h1>
41-
</chakra.a>
42-
</CFlex>
43-
<CFlex flex="1" justify-content="center">
44-
<CIcon name="search" mt="8px" />
45-
</CFlex>
46-
<CBox
47-
as="ul"
48-
d="flex"
49-
flex="1"
50-
align-items="center"
51-
list-style-type="none"
52-
pt="8px"
53-
justify-content="flex-end"
54-
>
55-
<CBox as="li" mr="2" :d="{ base: 'none', sm: 'block' }">
56-
<CIconButton
57-
as="a"
58-
variant-color="gray"
59-
aria-label="View GitHub"
60-
target="_blank"
61-
rel="noopener noreferrer"
62-
href="https://github.com/chakra-ui/chakra-ui-vue-next"
63-
icon="github"
64-
/>
65-
</CBox>
66-
<CBox as="li" mr="2" :d="{ base: 'none', sm: 'block' }">
67-
<CIconButton
68-
as="router-link"
69-
variant-color="gray"
70-
aria-label="View the documentation"
71-
to="#"
72-
icon="book"
73-
/>
74-
</CBox>
75-
<CBox as="li" mr="2" :d="{ base: 'none', sm: 'block' }">
76-
<CIconButton
77-
as="a"
78-
variant-color="gray"
79-
aria-label="Join Discord channel"
80-
target="_blank"
81-
rel="noopener noreferrer"
82-
href="https://discord.gg/sq2Kp6x"
83-
icon="discord"
84-
/>
85-
</CBox>
86-
<CBox as="li">
87-
<CIconButton
88-
as="a"
89-
variant-color="gray"
90-
aria-label="Open menu"
91-
target="_blank"
92-
rel="noopener noreferrer"
93-
href="https://discord.gg/sq2Kp6x"
94-
icon="menu"
95-
/>
96-
</CBox>
97-
</CBox>
98-
</chakra.nav>
99-
</template>
100-
1011
<script setup lang="ts">
2+
import ChakraLogo from "./ChakraLogo.vue"
3+
import ChakraLogoIcon from "./ChakraLogo.vue"
4+
import SponsorButton from "./SponsorButton.vue"
5+
// import { SearchButton } from "./AlgoliaSearch.vue"
6+
// import { MobileNavButton } from "./MobileNav.vue"
7+
import { VersionSwitcher } from "./VersionSwitcher.vue"
1028
import {
1039
chakra,
104-
CBadge,
10+
useColorMode,
11+
useColorModeValue,
10512
CBox,
13+
CHStack,
10614
CFlex,
10715
CIcon,
10816
CIconButton,
17+
CLink,
10918
} from "@chakra-ui/vue-next"
110-
import ChakraUILogoIcon from "./ChakraLogoIcon.vue"
111-
import pkg from "../../packages/core/package.json"
19+
import { useWindowScroll } from "@vueuse/core"
20+
import { computed, onMounted, ref } from "vue"
21+
import siteConfig from "@/config/site-config"
22+
23+
const { toggleColorMode } = useColorMode()
24+
const text = useColorModeValue("dark", "light")
25+
const switchIcon = useColorModeValue("moon", "sun")
26+
const bg = useColorModeValue("white", "gray.800")
27+
28+
const isOpen = ref(false)
29+
30+
const headerRef = ref<{ $el: HTMLDivElement } | undefined>(undefined)
31+
32+
const { y } = useWindowScroll()
33+
34+
const height = ref(0)
35+
36+
onMounted(() => {
37+
height.value = headerRef.value?.$el.getBoundingClientRect().height ?? 0
38+
})
39+
40+
const headerShadow = computed(() => {
41+
return y.value > height.value ? "sm" : undefined
42+
})
11243
</script>
44+
45+
<template>
46+
<chakra.header
47+
ref="headerRef"
48+
:box-shadow="headerShadow"
49+
transition="box-shadow 0.2s, background-color 0.2s"
50+
pos="sticky"
51+
top="0"
52+
zIndex="3"
53+
left="0"
54+
right="0"
55+
width="full"
56+
:bg="bg"
57+
backdrop-filter="saturate(120%) blur(5px)"
58+
border-top="6px solid"
59+
border-color="emerald.500"
60+
>
61+
<chakra.nav height="4.5rem" mx="auto" maxW="8xl">
62+
<!-- content -->
63+
64+
<CFlex w="100%" h="100%" px="6" align="center" justify="space-between">
65+
<CFlex align="center">
66+
<router-link to="/">
67+
<chakra.a
68+
display="block"
69+
aria-label="Chakra UI Vue, Back to homepage"
70+
>
71+
<ChakraLogo :display="{ base: 'none', md: 'block' }" />
72+
<CBox min-w="3rem" :display="{ base: 'block', md: 'none' }">
73+
<ChakraLogoIcon />
74+
</CBox>
75+
</chakra.a>
76+
</router-link>
77+
</CFlex>
78+
79+
<!-- nav -->
80+
<CFlex
81+
justify="flex-end"
82+
w="100%"
83+
maxW="1100px"
84+
align="center"
85+
color="gray.400"
86+
>
87+
<!-- <SearchButton></SearchButton> -->
88+
<VersionSwitcher></VersionSwitcher>
89+
<CHStack spacing="5" :display="{ base: 'none', md: 'flex' }">
90+
<CLink
91+
isExternal
92+
aria-label="Go to Chakra UI GitHub page"
93+
:href="siteConfig.repo.url"
94+
>
95+
<CIcon
96+
display="block"
97+
transition="color 0.2s"
98+
w="5"
99+
h="5"
100+
:_hover="{ color: 'gray.600' }"
101+
name="github"
102+
/>
103+
</CLink>
104+
<CLink
105+
isExternal
106+
aria-label="Go to Chakra UI Discord page"
107+
:href="siteConfig.discord"
108+
>
109+
<CIcon
110+
display="block"
111+
transition="color 0.2s"
112+
w="5"
113+
h="5"
114+
:_hover="{ color: 'gray.600' }"
115+
name="discord"
116+
/>
117+
</CLink>
118+
<CLink
119+
isExternal
120+
aria-label="Go to Chakra UI YouTube channel"
121+
:href="siteConfig.youtube"
122+
>
123+
<CIcon
124+
display="block"
125+
transition="color 0.2s"
126+
w="5"
127+
h="5"
128+
:_hover="{ color: 'gray.600' }"
129+
name="youtube"
130+
/>
131+
</CLink>
132+
</CHStack>
133+
<CIconButton
134+
size="md"
135+
fontSize="lg"
136+
:aria-label="`Switch to ${text} mode`"
137+
:title="`Switch to ${text} mode`"
138+
variant="ghost"
139+
color="current"
140+
:ml="{ base: '0', md: '3' }"
141+
@click="toggleColorMode"
142+
:icon="switchIcon"
143+
/>
144+
<SponsorButton ml="5" />
145+
<!-- <mobile-nav-button @click="isOpen = true"></mobile-nav-button> -->
146+
</CFlex>
147+
</CFlex>
148+
<!-- <mobile-nav :is-open="isOpen" @close="isOpen = false"></mobile-nav> -->
149+
</chakra.nav>
150+
</chakra.header>
151+
</template>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<script lang="tsx">
2+
import { defineComponent } from "vue"
3+
import { useColorModeValue, CBox } from "@chakra-ui/vue-next"
4+
import pkgJSON from "../../packages/core/package.json"
5+
export default {}
6+
7+
const versions = [
8+
{ label: `v${pkgJSON.version}`, url: "https://next.vue.chakra-ui.com/" },
9+
{ label: "v0.8.x", url: "https://vue.chakra-ui.com" },
10+
]
11+
12+
const v1Url = versions[0].url
13+
14+
export const VersionSwitcher = defineComponent({
15+
setup() {
16+
return () => {
17+
return (
18+
<CBox
19+
as="select"
20+
margin-end="1rem"
21+
variant="unstyled"
22+
fontWeight="semibold"
23+
color={useColorModeValue("gray.600", "whiteAlpha.600").value}
24+
bg="transparent"
25+
value={v1Url}
26+
fontSize="sm"
27+
flexShrink="0"
28+
display={{ base: "none", md: "flex" }}
29+
aria-label="Select the Chakra UI Docs version. You're currently viewing the version 1.0 docs"
30+
onChange={(e: any) => {
31+
document.location = e.target.value
32+
}}
33+
>
34+
{versions.map(({ label, url }) => (
35+
<option key={url} value={url}>
36+
{label}
37+
</option>
38+
))}
39+
</CBox>
40+
)
41+
}
42+
},
43+
})
44+
</script>

0 commit comments

Comments
 (0)