Skip to content

Commit fdba096

Browse files
authored
Feat/custom navbar cta (#2135)
* chore(): Add navbar cta schema * chore(navbar): Add Custom NavbarItem * chore(): Update config for cta navbar item
1 parent ba7b418 commit fdba096

File tree

5 files changed

+72
-1
lines changed

5 files changed

+72
-1
lines changed

Diff for: docusaurus-theme-classic/src/index.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ let { ThemeConfigSchema } = require(path.resolve(
1010
'../../node_modules/@docusaurus/theme-classic/lib/validateThemeConfig.js'
1111
));
1212

13+
const NavbarCtaSchema = Joi.object({
14+
type: Joi.string().equal('cta').required(),
15+
position: Joi.string().default('left'),
16+
text: Joi.string().required(),
17+
href: Joi.string().required(),
18+
});
1319
const NavbarIconLinkSchema = Joi.object({
1420
type: Joi.string().equal('iconLink').required(),
1521
position: Joi.string().default('left'),
@@ -29,7 +35,7 @@ const NavbarSeparatorSchema = Joi.object({
2935

3036
ThemeConfigSchema = ThemeConfigSchema.concat(
3137
Joi.object({
32-
navbar: { items: Joi.array().items(NavbarIconLinkSchema).items(NavbarSeparatorSchema) },
38+
navbar: { items: Joi.array().items(NavbarIconLinkSchema).items(NavbarSeparatorSchema).items(NavbarCtaSchema) },
3339
})
3440
);
3541

Diff for: docusaurus.config.js

+6
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ module.exports = {
6161
label: 'Native',
6262
position: 'left',
6363
},
64+
{
65+
type: 'cta',
66+
position: 'left',
67+
text: 'Ionic v6.0.0 Upgrade Guide',
68+
href: `${BASE_URL}/intro/upgrading-to-ionic-6`,
69+
},
6470
{
6571
type: 'docsVersionDropdown',
6672
position: 'right',

Diff for: src/styles/components/_navbar.scss

+36
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,42 @@ html[data-theme='dark'] {
5151
}
5252
}
5353
}
54+
55+
.cta {
56+
display: flex;
57+
align-items: center;
58+
59+
padding: 0.375rem 0.625rem;
60+
61+
background: linear-gradient(90deg, #495fff 0%, #18c6ff 114.68%);
62+
63+
color: #fff;
64+
65+
border-radius: 200px;
66+
67+
white-space: nowrap;
68+
69+
font-weight: 600;
70+
font-size: 0.75rem;
71+
line-height: 100%;
72+
73+
transition: opacity 0.2s ease-out;
74+
75+
margin-inline-start: 0.5rem;
76+
77+
@media (max-width: 1400px) {
78+
display: none;
79+
}
80+
81+
&:hover,
82+
&:active {
83+
opacity: 0.8;
84+
}
85+
86+
svg {
87+
margin-inline-start: 0.125rem;
88+
}
89+
}
5490
}
5591

5692
&__items--right {

Diff for: src/theme/NavbarItem/NavbarCta.tsx

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import clsx from 'clsx';
2+
import React from 'react';
3+
4+
export default function NavbarCta({ text, ...props }) {
5+
return (
6+
<a {...props} className={clsx(props.className, 'cta')}>
7+
{text}
8+
<svg xmlns="http://www.w3.org/2000/svg" class="ionicon" viewBox="0 0 512 512" width="12" height="12">
9+
<title>Arrow Forward</title>
10+
<path
11+
fill="none"
12+
stroke="currentColor"
13+
stroke-linecap="round"
14+
stroke-linejoin="round"
15+
stroke-width="48"
16+
d="M268 112l144 144-144 144M392 256H100"
17+
/>
18+
</svg>
19+
</a>
20+
);
21+
}

Diff for: src/theme/NavbarItem/index.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import OriginalNavbarItem from '@theme-original/NavbarItem';
22
import React from 'react';
33
import NavbarIconLink from '@theme/NavbarItem/NavbarIconLink';
44
import NavbarSeparator from '@theme/NavbarItem/NavbarSeparator';
5+
import NavbarCta from '@theme/NavbarItem/NavbarCta';
56

67
const CustomNavbarItemComponents = {
78
iconLink: () => NavbarIconLink,
89
separator: () => NavbarSeparator,
10+
cta: () => NavbarCta,
911
} as const;
1012

1113
export default function NavbarItem({ type, ...props }) {

0 commit comments

Comments
 (0)