Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
componentCategories,
collectionComponent,
parseComponentName,
elementComponent,
} from "@webstudio-is/sdk";
import type { Breakpoint, Page } from "@webstudio-is/sdk";
import type { TemplateMeta } from "@webstudio-is/template";
Expand Down Expand Up @@ -165,9 +164,6 @@ const $componentOptions = computed(
) {
continue;
}
if (isFeatureEnabled("element") === false && name === elementComponent) {
continue;
}

const componentMeta = metas.get(name);
const label =
Expand Down
3 changes: 0 additions & 3 deletions apps/builder/app/builder/features/components/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ const $metas = computed(
) {
continue;
}
if (isFeatureEnabled("element") === false && name === elementComponent) {
continue;
}

availableComponents.add(name);
metas.push({
Expand Down
23 changes: 14 additions & 9 deletions apps/builder/app/builder/shared/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
} from "@webstudio-is/sdk";
import type { Instance } from "@webstudio-is/sdk";
import { toast } from "@webstudio-is/design-system";
import { isFeatureEnabled } from "@webstudio-is/feature-flags";
import { createCommandsEmitter, type Command } from "~/shared/commands-emitter";
import {
$editingItemSelector,
Expand Down Expand Up @@ -528,15 +529,19 @@ export const { emitCommand, subscribeCommands } = createCommandsEmitter({
handler: () => unwrap(),
},

{
name: "pasteHtmlWithTailwindClasses",
handler: async () => {
const html = await navigator.clipboard.readText();
let fragment = generateFragmentFromHtml(html);
fragment = await generateFragmentFromTailwind(fragment);
return insertWebstudioFragmentAt(fragment);
},
},
...(isFeatureEnabled("tailwind")
? [
{
name: "pasteHtmlWithTailwindClasses",
handler: async () => {
const html = await navigator.clipboard.readText();
let fragment = generateFragmentFromHtml(html);
fragment = await generateFragmentFromTailwind(fragment);
return insertWebstudioFragmentAt(fragment);
},
},
]
: []),

// history

Expand Down
4 changes: 0 additions & 4 deletions apps/builder/app/shared/copy-paste/plugin-html.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { isFeatureEnabled } from "@webstudio-is/feature-flags";
import { generateFragmentFromHtml } from "../html";
import { insertWebstudioFragmentAt } from "../instance-utils";
import type { Plugin } from "./init-copy-paste";

export const html: Plugin = {
mimeType: "text/plain",
onPaste: (html: string) => {
if (!isFeatureEnabled("element")) {
return false;
}
const fragment = generateFragmentFromHtml(html);
return insertWebstudioFragmentAt(fragment);
},
Expand Down
20 changes: 20 additions & 0 deletions packages/css-engine/src/core/atomic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,23 @@ test("generate merged properties as single rule", () => {
}"
`);
});

test("convert :local-link to [aria-current=page] selector", () => {
const sheet = createRegularStyleSheet();
const rule = sheet.addNestingRule(".instance");
sheet.addMediaRule("x");
rule.setDeclaration({
breakpoint: "x",
selector: ":local-link",
property: "color",
value: { type: "keyword", value: "green" },
});
expect(generateAtomic(sheet, { getKey: () => "" }).cssText)
.toMatchInlineSnapshot(`
"@media all {
.c3mubaz[aria-current=page] {
color: green
}
}"
`);
});
6 changes: 5 additions & 1 deletion packages/css-engine/src/core/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,11 @@ export class NestingRule {
if (declaration.breakpoint !== breakpoint) {
continue;
}
const { selector: nestedSelector } = declaration;
let nestedSelector = declaration.selector;
// polyfill :local-link with framework specific logic
if (nestedSelector === ":local-link") {
nestedSelector = "[aria-current=page]";
}
const selector = this.#selector + this.#descendantSuffix + nestedSelector;
let style = styleBySelector.get(selector);
if (style === undefined) {
Expand Down
16 changes: 16 additions & 0 deletions packages/css-engine/src/core/style-sheet-regular.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -765,3 +765,19 @@ test("generate merged properties as single rule", () => {
}"
`);
});

test("convert :local-link to [aria-current=page] selector", () => {
const sheet = createRegularStyleSheet();
const rule = sheet.addNestingRule(".instance");
rule.setDeclaration({
breakpoint: "base",
selector: ":local-link",
property: "color",
value: { type: "keyword", value: "green" },
});
expect(rule.toString({ breakpoint: "base" })).toMatchInlineSnapshot(`
".instance[aria-current=page] {
color: green
}"
`);
});
2 changes: 1 addition & 1 deletion packages/feature-flags/src/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export const aiRadixComponents = false;
export const animation = false;
export const videoAnimation = false;
export const resourceProp = false;
export const element = false;
export const tailwind = false;
2 changes: 1 addition & 1 deletion packages/html-data/src/pseudo-classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const location = [
// ':link',
":visited",
// ':any-link',
// ':local-link',
":local-link",
// ':target',
// ':target-within',
];
Expand Down
4 changes: 0 additions & 4 deletions packages/sdk-components-react/src/box.ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ import {
import { props } from "./__generated__/box.props";

export const meta: WsComponentMeta = {
category: "general",
description:
"A container for content. By default this is a Div, but the tag can be changed in settings.",
presetStyle: {
div,
address,
Expand All @@ -29,7 +26,6 @@ export const meta: WsComponentMeta = {
nav,
section,
},
order: 0,
initialProps: ["tag", "id", "class"],
props: {
...props,
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-components-react/src/head-slot.template.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const meta: TemplateMeta = {
category: "general",
description:
"The Head Slot component lets you customize page-specific head elements (like canonical URLs), which merge with your site's global head settings, with Head Slot definitions taking priority over Page Settings. For site-wide head changes, use Project Settings instead.",
order: 6,
order: 5,
template: (
<$.HeadSlot>
<$.HeadTitle ws:label="Title">Title</$.HeadTitle>
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-components-react/src/html-embed.ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const meta: WsComponentMeta = {
label: "HTML Embed",
description: "Used to add HTML code to the page, such as an SVG or script.",
icon: EmbedIcon,
order: 2,
order: 3,
contentModel: {
category: "instance",
children: [descendantComponent],
Expand Down
9 changes: 0 additions & 9 deletions packages/sdk-components-react/src/link.template.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion packages/sdk-components-react/src/slot.ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export const meta: WsComponentMeta = {
description:
"Slot is a container for content that you want to reference across the project. Changes made to a Slot's children will be reflected in all other instances of that Slot.",
icon: SlotComponentIcon,
order: 5,
order: 4,
};
1 change: 0 additions & 1 deletion packages/sdk-components-react/src/templates.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export { meta as ContentEmbed } from "./content-embed.template";
export { meta as MarkdownEmbed } from "./markdown-embed.template";
export { meta as Link } from "./link.template";
export { meta as Form } from "./webhook-form.template";
export { meta as Vimeo } from "./vimeo.template";
export { meta as YouTube } from "./youtube.template";
Expand Down
7 changes: 4 additions & 3 deletions packages/sdk-components-react/src/vimeo.template.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PlayIcon, SpinnerIcon } from "@webstudio-is/icons/svg";
import { type TemplateMeta, $, css } from "@webstudio-is/template";
import { type TemplateMeta, $, css, ws } from "@webstudio-is/template";

export const meta: TemplateMeta = {
category: "media",
Expand Down Expand Up @@ -64,7 +64,8 @@ export const meta: TemplateMeta = {
`}
aria-label="Play button"
>
<$.Box
<ws.element
ws:tag="div"
ws:label="Play Icon"
ws:style={css`
width: 60px;
Expand All @@ -73,7 +74,7 @@ export const meta: TemplateMeta = {
aria-hidden={true}
>
<$.HtmlEmbed ws:label="Play SVG" code={PlayIcon} />
</$.Box>
</ws.element>
</$.VimeoPlayButton>
</$.Vimeo>
),
Expand Down
55 changes: 44 additions & 11 deletions packages/sdk-components-react/src/webhook-form.template.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {
$,
ws,
ActionValue,
css,
expression,
PlaceholderValue,
Variable,
Expand All @@ -20,28 +22,59 @@ export const meta: TemplateMeta = {
new ActionValue(["state"], expression`${formState} = state`)
}
>
<$.Box
<ws.element
ws:tag="div"
ws:label="Form Content"
ws:show={expression`${formState} === 'initial' || ${formState} === 'error'`}
>
<$.Label>{new PlaceholderValue("Name")}</$.Label>
<$.Input name="name" />
<$.Label>{new PlaceholderValue("Email")}</$.Label>
<$.Input name="email" />
<$.Button>{new PlaceholderValue("Submit")}</$.Button>
</$.Box>
<$.Box
<ws.element
ws:tag="label"
ws:style={css`
display: block;
`}
>
{new PlaceholderValue("Name")}
</ws.element>
<ws.element
ws:tag="input"
ws:style={css`
display: block;
`}
name="name"
/>
<ws.element
ws:tag="label"
ws:style={css`
display: block;
`}
>
{new PlaceholderValue("Email")}
</ws.element>
<ws.element
ws:tag="input"
ws:style={css`
display: block;
`}
name="email"
/>
<ws.element ws:tag="button">
{new PlaceholderValue("Submit")}
</ws.element>
</ws.element>
<ws.element
ws:tag="div"
ws:label="Success Message"
ws:show={expression`${formState} === 'success'`}
>
{new PlaceholderValue("Thank you for getting in touch!")}
</$.Box>
<$.Box
</ws.element>
<ws.element
ws:tag="div"
ws:label="Error Message"
ws:show={expression`${formState} === 'error'`}
>
{new PlaceholderValue("Sorry, something went wrong.")}
</$.Box>
</ws.element>
</$.Form>
),
};
7 changes: 4 additions & 3 deletions packages/sdk-components-react/src/youtube.template.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PlayIcon, SpinnerIcon } from "@webstudio-is/icons/svg";
import { type TemplateMeta, $, css } from "@webstudio-is/template";
import { type TemplateMeta, $, css, ws } from "@webstudio-is/template";

export const meta: TemplateMeta = {
label: "YouTube",
Expand Down Expand Up @@ -68,7 +68,8 @@ export const meta: TemplateMeta = {
`}
aria-label="Play button"
>
<$.Box
<ws.element
ws:tag="div"
ws:label="Play Icon"
ws:style={css`
width: 60px;
Expand All @@ -77,7 +78,7 @@ export const meta: TemplateMeta = {
aria-hidden={true}
>
<$.HtmlEmbed ws:label="Play SVG" code={PlayIcon} />
</$.Box>
</ws.element>
</$.VimeoPlayButton>
</$.YouTube>
),
Expand Down
Loading