Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions packages/sdk/src/core-metas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@ const collectionMeta: WsComponentMeta = {
},
};

export const pseudoComponent = "ws:pseudo";

const pseudoMeta: WsComponentMeta = {
label: "Pseudo-Element",
initialProps: [tagProperty],
props: {
[tagProperty]: {
type: "string",
control: "pseudo",
required: true,
options: ["::before", "::after"],
},
},
};

export const descendantComponent = "ws:descendant";

const descendantMeta: WsComponentMeta = {
Expand Down Expand Up @@ -123,8 +138,9 @@ const blockMeta: WsComponentMeta = {
export const coreMetas = {
[rootComponent]: rootMeta,
[elementComponent]: elementMeta,
[collectionComponent]: collectionMeta,
[pseudoComponent]: pseudoMeta,
[descendantComponent]: descendantMeta,
[collectionComponent]: collectionMeta,
[blockComponent]: blockMeta,
[blockTemplateComponent]: blockTemplateMeta,
};
Expand All @@ -134,8 +150,9 @@ export const coreMetas = {
export const isCoreComponent = (component: Instance["component"]) =>
component === rootComponent ||
component === elementComponent ||
component === collectionComponent ||
component === pseudoComponent ||
component === descendantComponent ||
component === collectionComponent ||
component === blockComponent ||
component === blockTemplateComponent;

Expand Down
12 changes: 9 additions & 3 deletions packages/sdk/src/core-templates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,9 @@ const forms: Record<string, TemplateMeta> = {
ws:style={css`
display: block;
`}
/>
>
<ws.pseudo ws:tag="::placeholder" />
</ws.element>
<ws.element ws:tag="button">
{new PlaceholderValue("Submit")}
</ws.element>
Expand Down Expand Up @@ -264,7 +266,9 @@ const forms: Record<string, TemplateMeta> = {
ws:style={css`
display: block;
`}
/>
>
<ws.pseudo ws:tag="::placeholder" />
</ws.element>
),
},

Expand All @@ -278,7 +282,9 @@ const forms: Record<string, TemplateMeta> = {
ws:style={css`
display: block;
`}
/>
>
<ws.pseudo ws:tag="::placeholder" />
</ws.element>
),
},

Expand Down
9 changes: 9 additions & 0 deletions packages/sdk/src/schema/prop-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ const Tag = z.object({
options: z.array(z.string()),
});

const Pseudo = z.object({
...common,
control: z.literal("pseudo"),
type: z.literal("string"),
defaultValue: z.undefined().optional(),
options: z.array(z.string()),
});

const Number = z.object({
...common,
control: z.literal("number"),
Expand Down Expand Up @@ -191,6 +199,7 @@ const AnimationAction = z.object({

export const PropMeta = z.union([
Tag,
Pseudo,
Number,
Range,
Text,
Expand Down