Skip to content

Commit

Permalink
More children preferredContents
Browse files Browse the repository at this point in the history
  • Loading branch information
gbalint committed May 31, 2024
1 parent b0718fd commit 7a3603f
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 17 deletions.
18 changes: 15 additions & 3 deletions utopia/layout.utopia.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Section,
Container,
} from '@h2/new/Layout'
import { DefaultTextContents } from './text.utopia.js'

export const BooleanSegmentControl = Utopia.radioControl([
{
Expand Down Expand Up @@ -39,7 +40,7 @@ const ColumnWithPlaceholdersVariant = {
</Flex>`,
}

const DefaultLayoutContent = [
const DefaultLayoutContents = [
{
component: 'Flex row',
moduleName: '@h2/new/Layout',
Expand Down Expand Up @@ -228,6 +229,13 @@ const annotations = {
RowWithPlaceholdersVariant,
ColumnWithPlaceholdersVariant,
],
children: {
preferredContents: [
...ContainerContents,
...DefaultLayoutContents,
...DefaultTextContents,
],
},
},
MultiColumn: {
component: MultiColumn,
Expand Down Expand Up @@ -308,7 +316,8 @@ const annotations = {
children: {
preferredContents: [
...ContainerContents,
...DefaultLayoutContent,
...DefaultLayoutContents,
...DefaultTextContents,
],
},
icon: 'dashedframe',
Expand Down Expand Up @@ -413,7 +422,10 @@ const annotations = {
sections: ['typography'],
},
children: {
preferredContents: [...DefaultLayoutContent],
preferredContents: [
...DefaultLayoutContents,
...DefaultTextContents,
],
},
variants: ContainerVariants,
icon: 'dashedframe',
Expand Down
53 changes: 39 additions & 14 deletions utopia/text.utopia.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,43 @@ const tshirtSizes = [
'6xl',
]

const HeadingVariants = tshirtSizes.map((size) => ({
label: `Heading (size ${size})`,
imports: `import { Heading } from '@h2/new/Text'`,
code: `<Heading size={'${size}'}>
Lorem ipsum
</ Heading>`,
}))

const TextVariants = tshirtSizes.map((size) => ({
label: `Text (size ${size})`,
imports: `import { Text } from '@h2/new/Text'`,
code: `<Text size={'${size}'}>
Lorem ipsum
</ Text>`,
}))

const HeadingContents = [
{
component: 'Heading',
moduleName: '@h2/new/Text',
variants: HeadingVariants,
},
]

const TextContents = [
{
component: 'Text',
moduleName: '@h2/new/Text',
variants: TextVariants,
},
]

export const DefaultTextContents = [
...HeadingContents,
...TextContents,
]

const annotations = {
Heading: {
component: Heading,
Expand Down Expand Up @@ -244,13 +281,7 @@ const annotations = {
},
focus: 'never',
inspector: 'hidden',
variants: tshirtSizes.map((size) => ({
label: `Heading (size ${size})`,
imports: `import { Heading } from '@h2/new/Text'`,
code: `<Heading size={'${size}'}>
Lorem ipsum
</ Heading>`,
})),
variants: HeadingVariants,
},
Text: {
component: Text,
Expand All @@ -264,13 +295,7 @@ const annotations = {
},
focus: 'never',
inspector: 'hidden',
variants: tshirtSizes.map((size) => ({
label: `Text (size ${size})`,
imports: `import { Text } from '@h2/new/Text'`,
code: `<Text size={'${size}'}>
Lorem ipsum
</ Text>`,
})),
variants: TextVariants,
},
Span: {
component: Span,
Expand Down

0 comments on commit 7a3603f

Please sign in to comment.