Skip to content

Commit

Permalink
minor icon adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchuman committed Feb 17, 2025
1 parent 83db30b commit cb16106
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 29 deletions.
6 changes: 3 additions & 3 deletions src/sanity/schemaTypes/modules/creative/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineArrayMember, defineField, defineType } from 'sanity'
import creativeCtas from './ctas.creative'
import creativeImage from './image.creative'
import creativeRichtext from './richtext.creative'
import creativeCtas from './ctas.creative'
import {
textAlign,
alignItems,
Expand Down Expand Up @@ -42,10 +42,10 @@ export default defineType({
name: 'subModules',
type: 'array',
of: [
{ type: 'icon' },
creativeCtas,
creativeImage,
{ type: 'icon' },
creativeRichtext,
creativeCtas,
{ type: 'custom-html' },
],
}),
Expand Down
2 changes: 2 additions & 0 deletions src/sanity/schemaTypes/objects/icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineField, defineType } from 'sanity'
import TextInputWithPresets, {
getPreset,
} from '@/sanity/ui/TextInputWithPresets'
import { VscSymbolMisc } from 'react-icons/vsc'

const sizePresets = ['2.5rem', '80px', '1.5lh']

Expand All @@ -16,6 +17,7 @@ const ic0nPresets =
export default defineType({
name: 'icon',
title: 'Icon',
icon: VscSymbolMisc,
type: 'object',
options: {
columns: 2,
Expand Down
54 changes: 28 additions & 26 deletions src/ui/modules/CreativeModule/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ export default function CreativeModule({
intro: any
modules: Partial<{
subModules: Array<
| CTAsSubModuleType
| CustomHTMLSubmoduleType
| Sanity.Icon
| ImageSubModuleType
| Sanity.Icon
| RichtextSubModuleType
| CTAsSubModuleType
| CustomHTMLSubmoduleType
>
colSpan: number
}>[]
Expand Down Expand Up @@ -76,46 +76,48 @@ export default function CreativeModule({
>
{subModules?.map((subModule, ii) => {
switch (subModule._type) {
case 'ctas':
case 'image':
return (
<CTAsSubModule
<ImageSubModule
module={subModule}
className={cn(
stegaClean(textAlign) === 'center' &&
'justify-center',
)}
width={width * colSpan}
key={ii}
/>
)

case 'custom-html':
return <CustomHTMLSubmodule module={subModule} />

case 'icon':
return (
<figure style={{ height: getPixels(subModule?.size) }}>
<Icon
icon={subModule}
className={cn(
stegaClean(textAlign) === 'center' &&
'[&_img]:mx-auto',
)}
key={ii}
/>
<figure
className={cn(
stegaClean(textAlign) === 'center' &&
'[&_img]:mx-auto',
)}
style={{ height: getPixels(subModule?.size) }}
>
<Icon icon={subModule} key={ii} />
</figure>
)

case 'image':
case 'richtext':
return <RichtextSubModule module={subModule} key={ii} />

case 'ctas':
return (
<ImageSubModule
<CTAsSubModule
module={subModule}
width={width * colSpan}
className={cn(
stegaClean(textAlign) === 'center' &&
'justify-center',
)}
key={ii}
/>
)

case 'richtext':
return <RichtextSubModule module={subModule} key={ii} />
case 'custom-html':
return <CustomHTMLSubmodule module={subModule} />

default:
return null
}
})}
</article>
Expand Down

0 comments on commit cb16106

Please sign in to comment.