Skip to content

Commit

Permalink
feat: X and Slack to SocialLinks prop controller
Browse files Browse the repository at this point in the history
  • Loading branch information
migueloller committed Mar 1, 2024
1 parent 665f6e1 commit 88fb167
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 35 deletions.
5 changes: 5 additions & 0 deletions .changeset/popular-pets-allow.md
@@ -0,0 +1,5 @@
---
'@makeswift/runtime': patch
---

Add X and Slack icons to legacy `SocialLinks` prop controller.
86 changes: 51 additions & 35 deletions packages/runtime/src/prop-controllers/descriptors.ts
Expand Up @@ -991,46 +991,62 @@ export function getShapePropControllerSwatchIds(
return introspectShapePropControllerData(descriptor, value, getSwatchIds)
}

type SocialLinkType =
| 'angellist'
| 'codepen'
| 'discord'
| 'dribbble'
| 'facebook'
| 'github'
| 'instagram'
| 'linkedin'
| 'medium'
| 'pinterest'
| 'reddit'
| 'rss'
| 'snapchat'
| 'soundcloud'
| 'spotify'
| 'telegram'
| 'tumblr'
| 'twitch'
| 'twitter'
| 'vimeo'
| 'whatsapp'
| 'yelp'
| 'youtube'

type SocialLink = { type: SocialLinkType; url: string }

type SocialLinksLink = { id: string; payload: SocialLink }

export type SocialLinksValue = { links: SocialLinksLink[]; openInNewTab: boolean }

type SocialLinksOptions = Options<{ preset?: SocialLinksValue }>

type SocialLinksDescriptor<_T = SocialLinksValue> = {
export const socialLinkTypesV0 = [
'angellist',
'codepen',
'discord',
'dribbble',
'facebook',
'github',
'instagram',
'linkedin',
'medium',
'pinterest',
'reddit',
'rss',
'snapchat',
'soundcloud',
'spotify',
'telegram',
'tumblr',
'twitch',
'twitter',
'vimeo',
'whatsapp',
'yelp',
'youtube',
] as const

type SocialLinkTypeV0 = typeof socialLinkTypesV0[number]

export const socialLinkTypesV1 = [...socialLinkTypesV0, 'x', 'slack'] as const

type SocialLinkTypeV1 = typeof socialLinkTypesV1[number]

type SocialLinkV0 = { type: SocialLinkTypeV0; url: string }

type SocialLinkV1 = { type: SocialLinkTypeV1; url: string }

type SocialLinksLinkV0 = { id: string; payload: SocialLinkV0 }

type SocialLinksLinkV1 = { id: string; payload: SocialLinkV1 }

type SocialLinksValueV0 = { links: SocialLinksLinkV0[]; openInNewTab: boolean }

type SocialLinksValueV1 = { links: SocialLinksLinkV1[]; openInNewTab: boolean }

export type SocialLinksValue = SocialLinksValueV0 | SocialLinksValueV1

type SocialLinksOptions = Options<{ preset?: SocialLinksValueV1 }>

export type SocialLinksDescriptor<_T = SocialLinksValueV1> = {
type: typeof Types.SocialLinks
options: SocialLinksOptions
version?: 1
}

export function SocialLinks(options: SocialLinksOptions = {}): SocialLinksDescriptor {
return { type: Types.SocialLinks, options }
return { type: Types.SocialLinks, options, version: 1 }
}

export type TableValue = string
Expand Down
3 changes: 3 additions & 0 deletions packages/runtime/src/prop-controllers/index.ts
Expand Up @@ -63,7 +63,10 @@ export type {
PanelDescriptorValueType,
ResponsiveValue,
ResponsiveValueType,
SocialLinksDescriptor,
SocialLinksValue,
} from './descriptors'
export { socialLinkTypesV0, socialLinkTypesV1 } from './descriptors'
export * as Props from './descriptors'
export type {
PropControllerMessage,
Expand Down

0 comments on commit 88fb167

Please sign in to comment.