Skip to content

Commit

Permalink
update cta schema
Browse files Browse the repository at this point in the history
  • Loading branch information
milewskibogumil committed Oct 16, 2024
1 parent a4fba3c commit f3785b6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
2 changes: 1 addition & 1 deletion apps/astro/src/components/ui/button/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const ButtonDataQuery = (name: string) => `
${name} {
text,
theme,
"linkType": type,
linkType,
"href": select(type == "internal" => internal -> slug.current, type == "external" => external, "#"),
},
`
10 changes: 6 additions & 4 deletions apps/astro/src/global/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,10 @@ body {
overflow-x: clip;
}
html {
scroll-behavior: smooth;
scroll-padding-top: 123px;
@media (prefers-reduced-motion: no-preference) {
scroll-behavior: smooth;
}
}
body {
overflow: clip;
Expand All @@ -149,8 +151,8 @@ body {
color: var(--secondary-700, #0c2d63);
font-family: 'Fixel', sans-serif;
font-size: 1rem;
line-height: 158%;
letter-spacing: -0.005em;
line-height: 165%;
letter-spacing: 0.005rem;
}

main,
Expand All @@ -175,7 +177,7 @@ h6,
.h6 {
overflow-wrap: anywhere;
font-weight: 400;
line-height: 120%;
line-height: 135%;
color: var(--secondary-700, #0c2d63);
font-variant-numeric: lining-nums tabular-nums;
strong {
Expand Down
31 changes: 25 additions & 6 deletions apps/sanity/schema/ui/cta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { isValidUrl } from "../../utils/is-valid-url";
import { InternalLinkableTypes } from "../../structure/internal-linkable-types";

const name = 'cta';
const title = 'Call to action';
const title = 'Call To Action (CTA)';
const icon = () => '🗣️';

export default defineType({
Expand All @@ -24,34 +24,44 @@ export default defineType({
name: 'theme',
type: 'string',
title: 'Theme',
description: 'Theme is used to style the button. Choose "Primary" for the main call to action, or "Secondary" for less important actions.',
description: (
<>
<em>Primary</em> (main button) or <em>Secondary</em> (less important)
</>
),
options: {
list: ['primary', 'secondary'],
layout: 'radio',
direction: 'horizontal',
},
initialValue: 'primary',
validation: Rule => Rule.required(),
fieldset: 'style',
}),
defineField({
name: 'type',
name: 'linkType',
type: 'string',
title: 'Type',
description: 'Choose "External" for links to websites outside your domain, or "Internal" for links to pages within your site.',
description: (
<>
<em>External</em> (other websites) or <em>Internal</em> (within your site)
</>
),
options: {
list: ['external', 'internal'],
layout: 'radio',
direction: 'horizontal',
},
initialValue: 'external',
validation: Rule => Rule.required(),
fieldset: 'style',
}),
defineField({
name: 'external',
type: 'string',
title: 'URL',
description: 'Specify the full URL. Ensure it starts with "https://" and is a valid URL.',
hidden: ({ parent }) => parent?.type !== 'external',
hidden: ({ parent }) => parent?.linkType !== 'external',
validation: (Rule) => [
Rule.custom((value, { parent }) => {
const type = (parent as { type?: string })?.type;
Expand All @@ -76,7 +86,7 @@ export default defineType({
disableNew: true,
filter: 'defined(slug.current)',
},
hidden: ({ parent }) => parent?.type !== 'internal',
hidden: ({ parent }) => parent?.linkType !== 'internal',
validation: (rule) => [
rule.custom((value, { parent }) => {
const type = (parent as { type?: string })?.type;
Expand All @@ -86,6 +96,15 @@ export default defineType({
],
}),
],
fieldsets: [
{
name: 'style',
title: 'Style',
options: {
columns: 2,
}
},
],
preview: {
select: {
title: 'text',
Expand Down

0 comments on commit f3785b6

Please sign in to comment.