Skip to content

Commit d881c3e

Browse files
committed
Slickify
1 parent c9f9b90 commit d881c3e

23 files changed

+364
-134
lines changed

common/src/styles/base.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,9 @@ button, td-button {
268268
@include card-padding;
269269
transition: border-color 100ms;
270270

271-
&.hoverable:hover {
272-
border-color: var(--color-secondary-light-grey);
273-
}
271+
//&.hoverable:hover {
272+
// border-color: var(--color-secondary-light-grey);
273+
//}
274274
}
275275

276276
.card-appearance {

schema/common-fields.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,30 @@ export const learnMoreLinkFieldOptional = Object.assign({}, linkFieldOptional, {
174174
title: "'Learn More' link",
175175
});
176176

177+
export const iconNameFieldName = "iconName";
178+
export const iconVariantFieldName = "iconVariant";
179+
180+
export const iconNameFieldOptional = defineField({
181+
name: "iconName",
182+
type: "string",
183+
title: "Icon Name",
184+
});
185+
186+
export const iconVariantFieldOptional = defineField({
187+
name: "iconVariant",
188+
type: "string",
189+
title: "Icon Variant",
190+
initialValue: "thin",
191+
options: {
192+
list: ["regular", "light", "thin", "brands"],
193+
layout: "radio",
194+
direction: "horizontal",
195+
},
196+
hidden: (ctx) => {
197+
return ctx.parent == null || ctx.parent["iconName"] == null;
198+
},
199+
});
200+
177201
export const comingSoonField = defineField({
178202
name: "comingSoon",
179203
title: "Coming soon?",
@@ -231,6 +255,16 @@ export const keywordFieldOptional = defineField({
231255
type: "string",
232256
});
233257

258+
export const tagsFieldName = "tags";
259+
260+
export const tagsField = defineField({
261+
name: tagsFieldName,
262+
title: "Tags",
263+
type: "array",
264+
of: [{ type: "string" }],
265+
initialValue: [],
266+
});
267+
234268
export interface SanityVisibleToggle {
235269
isVisible: boolean;
236270
}

schema/component/feature-grid.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { DashboardIcon } from "@sanity/icons";
22
import { ArrayRule, defineField, defineType, SanityDocument } from "@sanity/types";
33
import { CodeSnippetShort, codeSnippetShortSchemaName, isCodeSnippetShort } from "../code";
4-
import { bodyFieldRichText, isVisibleField, nameField, requiredRule, SanityVisibleToggle, sectionIconField, sectionIconFieldOptional, titleFieldOptional, titleFieldWithHighlights } from "../common-fields";
4+
import { bodyFieldRichText, isVisibleField, nameField, requiredRule, SanityVisibleToggle, sectionIconField, sectionIconFieldOptional, tagsField, titleFieldOptional, titleFieldWithHighlights } from "../common-fields";
55
import { Illustration, illustrationFieldOptional, illustrationFieldTargetTypes, illustrationFromSanity, SanityIllustration } from "../illustration";
66
import { SanityImageRef } from "../image";
77
import { SanityTextLink, TextLink, textLinkSchemaName } from "../link";
@@ -156,13 +156,7 @@ const featureGridCellSchema = defineType({
156156
type: "array",
157157
of: [{type: textLinkSchemaName}],
158158
}),
159-
defineField({
160-
name: "tags",
161-
title: "Tags",
162-
type: "array",
163-
of: [{ type: "string" }],
164-
initialValue: [],
165-
}),
159+
tagsField,
166160
defineField({
167161
name: "isIllustrationBlurred",
168162
title: "Blur Illustration?",

schema/component/index.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,14 @@ import { conclusionPanelSchemas } from "./conclusion-panel";
22
import { contentTextPanelSchemas } from "./content-text-panel";
33
import { featureGridSchemas } from "./feature-grid";
44
import { featureTableSchemas } from "./feature-table";
5+
import { integrationsGridSchemas } from "./integrations-grid";
56
import { linkPanelSchemas } from "./link-panel";
67
import { pageSectionSchemas } from "./section";
78
import { pricingPanelSchemas } from "./pricing-panel";
89
import { publicationSchemas } from "./publication-panel";
910

1011
export const componentSchemas: any[] = [
11-
...conclusionPanelSchemas,
12-
...contentTextPanelSchemas,
13-
...featureGridSchemas,
14-
...featureTableSchemas,
15-
...linkPanelSchemas,
16-
...pageSectionSchemas,
17-
...pricingPanelSchemas,
12+
...conclusionPanelSchemas, ...contentTextPanelSchemas, ...featureGridSchemas, ...featureTableSchemas,
13+
...integrationsGridSchemas, ...linkPanelSchemas, ...pageSectionSchemas, ...pricingPanelSchemas,
1814
...publicationSchemas,
1915
];

schema/component/integrations-grid.ts

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
import { DashboardIcon } from "@sanity/icons";
2+
import { ArrayRule, defineField, defineType, SanityDocument } from "@sanity/types";
3+
import { CodeSnippetShort, codeSnippetShortSchemaName, isCodeSnippetShort } from "../code";
4+
import { actionsFieldOptional, bodyFieldRichText, imageFieldOptional, isVisibleField, linkFieldOptional, nameField, requiredRule, SanityVisibleToggle, sectionIconField, sectionIconFieldOptional, tagsField, titleBodyIconFields, titleFieldOptional, titleFieldWithHighlights } from "../common-fields";
5+
import { Illustration, illustrationFieldOptional, illustrationFieldTargetTypes, illustrationFromSanity, SanityIllustration } from "../illustration";
6+
import { SanityImageRef } from "../image";
7+
import { Link, SanityLink, SanityTextLink, TextLink, textLinkSchemaName } from "../link";
8+
import { SanityDataset, SanityImage, SanityReference } from "../sanity-core";
9+
import { BodyTextField, PortableText } from "../text";
10+
import { PropsOf } from "../util";
11+
import { SanitySectionBase, SectionBase } from "./section";
12+
13+
export interface SanityIntegrationsGridSection extends SanitySectionBase, SanityVisibleToggle {
14+
primary: SanityIntegration[];
15+
secondary: SanityIntegration[];
16+
requestLink?: SanityTextLink;
17+
}
18+
19+
export interface SanityIntegration extends SanityVisibleToggle {
20+
name: string;
21+
image?: SanityImage;
22+
link?: SanityReference<SanityLink>;
23+
tags: string[];
24+
}
25+
26+
export class Integration {
27+
readonly name: string;
28+
readonly imageURL?: string;
29+
readonly link?: Link;
30+
readonly tags: string[];
31+
32+
constructor(props: PropsOf<Integration>) {
33+
this.name = props.name;
34+
this.imageURL = props.imageURL;
35+
this.link = props.link;
36+
this.tags = props.tags;
37+
}
38+
39+
static fromSanity(data: SanityIntegration, db: SanityDataset) {
40+
return new Integration({
41+
name: data.name,
42+
imageURL: data.image && db.resolveRef(data.image.asset).url,
43+
link: data.link ? Link.fromSanityLinkRef(data.link, db) : undefined,
44+
tags: data.tags,
45+
});
46+
}
47+
}
48+
49+
export class IntegrationsGridSection extends SectionBase {
50+
readonly primary: Integration[];
51+
readonly secondary: Integration[];
52+
readonly requestLink?: TextLink;
53+
54+
constructor(props: PropsOf<IntegrationsGridSection>) {
55+
super(props);
56+
this.primary = props.primary;
57+
this.secondary = props.secondary;
58+
this.requestLink = props.requestLink;
59+
}
60+
61+
static override fromSanity(data: SanityIntegrationsGridSection, db: SanityDataset) {
62+
const visiblePrimaries = data.primary.filter((x) => x.isVisible);
63+
const visibleSecondaries = data.secondary.filter((x) => x.isVisible);
64+
return new IntegrationsGridSection(Object.assign(SectionBase.fromSanity(data, db), {
65+
primary: visiblePrimaries.map(x => Integration.fromSanity(x, db)),
66+
secondary: visibleSecondaries.map(x => Integration.fromSanity(x, db)),
67+
requestLink: data.requestLink ? TextLink.fromSanityTextLink(data.requestLink, db) : undefined,
68+
}));
69+
}
70+
}
71+
72+
export const integrationSchemaName = `integration`;
73+
74+
const integrationSchema = defineType({
75+
name: integrationSchemaName,
76+
title: "Integration",
77+
type: "object",
78+
fields: [
79+
nameField,
80+
imageFieldOptional,
81+
linkFieldOptional,
82+
tagsField,
83+
isVisibleField,
84+
],
85+
});
86+
87+
export const integrationsGridSectionSchemaName = `integrationsGridSection`;
88+
89+
const integrationsGridSectionSchema = defineType({
90+
name: integrationsGridSectionSchemaName,
91+
title: "Integrations Grid Section",
92+
type: "document",
93+
icon: DashboardIcon,
94+
fields: [
95+
...titleBodyIconFields,
96+
actionsFieldOptional,
97+
isVisibleField,
98+
defineField({
99+
name: "primary",
100+
title: "Primary",
101+
type: "array",
102+
of: [{ type: integrationSchemaName }],
103+
}),
104+
defineField({
105+
name: "secondary",
106+
title: "Secondary",
107+
type: "array",
108+
of: [{ type: integrationSchemaName }],
109+
}),
110+
defineField({
111+
name: "requestLink",
112+
title: "Request Link",
113+
type: textLinkSchemaName,
114+
}),
115+
illustrationFieldOptional,
116+
],
117+
});
118+
119+
export const integrationsGridSchemas = [integrationSchema, integrationsGridSectionSchema];

schema/component/link-panel.ts

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,56 @@
11
import { defineField, defineType } from "@sanity/types";
2-
import { SanityImageRef } from "../image";
3-
import { bodyFieldRichText, buttonField, requiredRule, sectionIconField, textLinkFieldOptional, titleField } from "../common-fields";
2+
import { bodyFieldRichText, buttonField, iconNameFieldOptional, iconVariantFieldOptional, requiredRule, textLinkFieldOptional, titleField } from "../common-fields";
43
import { SanityTextLink, TextLink } from "../link";
5-
import { SanityDataset, SanityReference } from "../sanity-core";
4+
import { SanityDataset } from "../sanity-core";
65
import { BodyTextField, PortableText } from "../text";
76
import { PropsOf } from "../util";
87

98
export interface SanityLinkPanel {
109
title: string;
1110
body: PortableText;
12-
}
13-
14-
export interface SanityLinkPanelWithIcon extends SanityLinkPanel {
15-
icon: SanityReference<SanityImageRef>;
11+
iconName?: string;
12+
iconVariant?: string;
1613
link?: SanityTextLink;
1714
}
1815

1916
export class LinkPanel implements BodyTextField {
2017
readonly title: string;
2118
readonly body: PortableText;
19+
readonly iconName?: string;
20+
readonly iconVariant?: string;
21+
readonly link?: TextLink;
2222

2323
constructor(props: PropsOf<LinkPanel>) {
2424
this.title = props.title;
2525
this.body = props.body;
26+
this.iconName = props.iconName;
27+
this.iconVariant = props.iconVariant;
28+
this.link = props.link;
2629
}
2730

28-
static fromSanity(data: SanityLinkPanel, _db: SanityDataset): LinkPanel {
31+
static fromSanity(data: SanityLinkPanel, db: SanityDataset): LinkPanel {
2932
return new LinkPanel({
3033
title: data.title,
3134
body: data.body,
32-
});
33-
}
34-
}
35-
36-
export class LinkPanelWithIcon extends LinkPanel {
37-
readonly iconURL: string;
38-
readonly link?: TextLink;
39-
40-
constructor(props: PropsOf<LinkPanelWithIcon>) {
41-
super(props);
42-
this.iconURL = props.iconURL;
43-
this.link = props.link;
44-
}
45-
46-
static override fromSanity(data: SanityLinkPanelWithIcon, db: SanityDataset): LinkPanelWithIcon {
47-
return new LinkPanelWithIcon(Object.assign(LinkPanel.fromSanity(data, db), {
48-
iconURL: db.resolveImageRef(data.icon).url,
35+
iconName: data.iconName,
36+
iconVariant: data.iconVariant,
4937
link: data.link ? TextLink.fromSanityTextLink(data.link, db) : undefined,
50-
}));
38+
});
5139
}
5240
}
5341

54-
export const linkPanelWithIconSchemaName = "linkPanelWithIcon";
42+
export const linkPanelSchemaName = `linkPanel`;
5543

56-
const linkPanelWithIconSchema = defineType({
57-
name: linkPanelWithIconSchemaName,
44+
const linkPanelSchema = defineType({
45+
name: linkPanelSchemaName,
5846
title: "Link Panel",
5947
type: "object",
6048
fields: [
6149
titleField,
6250
bodyFieldRichText,
63-
sectionIconField,
6451
textLinkFieldOptional,
52+
iconNameFieldOptional,
53+
iconVariantFieldOptional,
6554
],
6655
});
6756

@@ -86,4 +75,4 @@ const productPanelSchema = defineType({
8675
],
8776
});
8877

89-
export const linkPanelSchemas = [linkPanelWithIconSchema, productPanelSchema];
78+
export const linkPanelSchemas = [linkPanelSchema, productPanelSchema];

schema/component/section.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import {
66
import { SanityDataset } from "../sanity-core";
77
import { BodyTextField, ParagraphWithHighlights, PortableText, SanityTitleBodyActions } from "../text";
88
import { PropsOf } from "../util";
9-
import { LinkPanelWithIcon, linkPanelWithIconSchemaName, SanityLinkPanelWithIcon } from "./link-panel";
109
import { ContentTextPanel, contentTextPanelSchemaName, SanityContentTextPanel } from "./content-text-panel";
10+
import { LinkPanel, linkPanelSchemaName, SanityLinkPanel } from "./link-panel";
1111

1212
export interface SanitySectionBase extends SanityTitleBodyActions, SanityIconField {
1313
keyword?: string;
@@ -20,7 +20,7 @@ export interface SanityTitleBodyPanelSection extends SanityCoreSection {
2020
}
2121

2222
export interface SanityLinkPanelsSection extends SanityCoreSection {
23-
panels: SanityLinkPanelWithIcon[];
23+
panels: SanityLinkPanel[];
2424
}
2525

2626
export class SectionBase implements Partial<BodyTextField> {
@@ -67,7 +67,7 @@ export class TitleBodyPanelSection extends SectionBase {
6767
}
6868

6969
export class LinkPanelsSection extends SectionBase {
70-
readonly panels: LinkPanelWithIcon[];
70+
readonly panels: LinkPanel[];
7171

7272
constructor(props: PropsOf<LinkPanelsSection>) {
7373
super(props);
@@ -77,7 +77,7 @@ export class LinkPanelsSection extends SectionBase {
7777
static override fromSanity(data: SanityLinkPanelsSection, db: SanityDataset) {
7878
return new LinkPanelsSection({
7979
...super.fromSanity(data, db),
80-
panels: data.panels.map((x) => LinkPanelWithIcon.fromSanity(x, db)),
80+
panels: data.panels.map((x) => LinkPanel.fromSanity(x, db)),
8181
});
8282
}
8383
}
@@ -132,7 +132,7 @@ const linkPanelsSectionSchema = defineType({
132132
name: "panels",
133133
title: "Panels",
134134
type: "array",
135-
of: [{ type: linkPanelWithIconSchemaName }],
135+
of: [{ type: linkPanelSchemaName }],
136136
validation: (rule) => rule.required().length(3),
137137
}),
138138
isVisibleField,

schema/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ export {
4343
FeatureGrid, type FeatureGridLayout, FeatureGridSection, FeatureGridCell, featureGridSchemaName,
4444
} from "./component/feature-grid";
4545
export { FeatureTable, featureTableSchemaName, type FeatureTableCell } from "./component/feature-table";
46-
export { LinkPanel, LinkPanelWithIcon } from "./component/link-panel";
46+
export { Integration, IntegrationsGridSection } from "./component/integrations-grid";
47+
export { LinkPanel } from "./component/link-panel";
4748
export { TitleBodyPanelSection } from "./component/section";
4849
export { PricingPanel, type SanityPricingPanel } from "./component/pricing-panel";
4950
export {

0 commit comments

Comments
 (0)