Skip to content
Merged
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
6 changes: 5 additions & 1 deletion apps/builder/app/builder/features/components/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type Meta = {
label: string;
description: undefined | string;
icon?: string;
firstInstance: { component: string; tag?: string };
};

const $metas = computed(
Expand Down Expand Up @@ -87,6 +88,7 @@ const $metas = computed(
order: componentMeta.order,
label: getInstanceLabel({ component: name }, componentMeta),
description: componentMeta.description,
firstInstance: { component: name },
});
}
for (const [name, templateMeta] of templates) {
Expand All @@ -103,6 +105,7 @@ const $metas = computed(
continue;
}

availableComponents.add(name);
metas.push({
name,
category: templateMeta.category ?? "hidden",
Expand All @@ -113,6 +116,7 @@ const $metas = computed(
getInstanceLabel({ component: name }, templateMeta),
description: templateMeta.description,
icon: templateMeta.icon,
firstInstance: templateMeta.template.instances[0],
});
}
const metasByCategory = mapGroupBy(metas, (meta) => meta.category);
Expand Down Expand Up @@ -339,7 +343,7 @@ export const ComponentsPanel = ({
icon={
<InstanceIcon
size="auto"
instance={{ component: meta.name }}
instance={meta.firstInstance}
// for cases like Sheet template
icon={meta.icon}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ export const TagControl = ({ meta, prop }: ControlProps<"tag">) => {
>
{options.length > 10 ? (
<Combobox<string>
defaultHighlightedIndex={0}
getItems={() => options}
itemToString={(item) => item ?? options[0]}
value={value ?? computedTag}
selectedItem={computedTag}
onChange={(value) => setValue(value ?? undefined)}
onItemSelect={(item) => {
updateTag(item);
setValue(undefined);
}}
itemToString={(item) => item ?? options[0]}
value={value ?? computedTag}
onChange={(value) => setValue(value ?? undefined)}
getDescription={(item) => (
<Box css={{ width: theme.spacing[28] }}>
{elementsByTag[item ?? ""]?.description}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import { useId, useMemo } from "react";
import { useMemo } from "react";
import { useStore } from "@nanostores/react";
import { computed } from "nanostores";
import { Flex, rawTheme, Text, TextArea } from "@webstudio-is/design-system";
import {
DialogClose,
DialogMaximize,
DialogTitle,
DialogTitleActions,
Flex,
rawTheme,
Text,
} from "@webstudio-is/design-system";
import type { Instance } from "@webstudio-is/sdk";
import { AlertIcon } from "@webstudio-is/icons";
import { $instances } from "~/shared/nano-states";
Expand All @@ -10,6 +18,7 @@ import {
BindingPopover,
} from "~/builder/shared/binding-popover";
import { updateWebstudioData } from "~/shared/instance-utils";
import { CodeEditor } from "~/builder/shared/code-editor";
import {
type ControlProps,
useLocalValue,
Expand Down Expand Up @@ -55,7 +64,6 @@ export const TextContent = ({
updateChildren(instanceId, "text", value);
}
});
const id = useId();

const { scope, aliases } = useStore($selectedInstanceScope);
let expression: undefined | string;
Expand Down Expand Up @@ -107,15 +115,24 @@ export const TextContent = ({
}
>
<BindingControl>
<TextArea
id={id}
disabled={overwritable === false}
autoGrow
<CodeEditor
title={
<DialogTitle
suffix={
<DialogTitleActions>
<DialogMaximize />
<DialogClose />
</DialogTitleActions>
}
>
<Text variant="labelsTitleCase">Text Content</Text>
</DialogTitle>
}
size="small"
readOnly={overwritable === false}
value={localValue.value}
rows={1}
onChange={localValue.set}
onBlur={localValue.save}
onSubmit={localValue.save}
onChangeComplete={localValue.save}
/>
{expression !== undefined && (
<BindingPopover
Expand Down
5 changes: 4 additions & 1 deletion apps/builder/app/builder/shared/code-editor-base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,17 @@ const editorContentStyle = css({
boxSizing: "border-box",
color: theme.colors.foregroundMain,
borderRadius: theme.borderRadius[4],
border: `1px solid ${theme.colors.borderMain}`,
border: `1px solid transparent`,
background: theme.colors.backgroundControls,
paddingTop: 4,
paddingBottom: 2,
paddingRight: theme.spacing[2],
paddingLeft: theme.spacing[3],
// required to support copying selected text
userSelect: "text",
"&:hover": {
borderColor: theme.colors.borderMain,
},
"&:focus-within": {
borderColor: theme.colors.borderFocus,
},
Expand Down
4 changes: 2 additions & 2 deletions apps/builder/app/builder/shared/code-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const wrapperStyle = css({
variants: {
size: {
default: getMinMaxHeightVars({ minHeight: "160px", maxHeight: "320px" }),
keyframe: getMinMaxHeightVars({ minHeight: "60px", maxHeight: "120px" }),
small: getMinMaxHeightVars({ minHeight: "16px", maxHeight: "120px" }),
},
},
defaultVariants: {
Expand Down Expand Up @@ -120,7 +120,7 @@ export const CodeEditor = forwardRef<
Omit<ComponentProps<typeof EditorContent>, "extensions"> & {
lang?: "html" | "markdown" | "css-properties";
title?: ReactNode;
size?: "default" | "keyframe";
size?: "default" | "small";
}
>(({ lang, title, size, ...editorContentProps }, ref) => {
const extensions = useMemo(() => {
Expand Down
2 changes: 2 additions & 0 deletions apps/builder/app/builder/shared/instance-label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
BodyIcon,
BoldIcon,
BoxIcon,
BracesIcon,
ButtonElementIcon,
CalendarIcon,
FormIcon,
Expand Down Expand Up @@ -42,6 +43,7 @@ const htmlIcons: Record<string, undefined | string> = {
h6: HeadingIcon,
p: TextAlignLeftIcon,
blockquote: BlockquoteIcon,
code: BracesIcon,
ul: ListIcon,
ol: ListIcon,
li: ListItemIcon,
Expand Down
1 change: 1 addition & 0 deletions apps/builder/app/shared/content-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ export const richTextPlaceholders: Map<undefined | string, string> = new Map([
["h6", "Heading 6"],
["p", "Paragraph"],
["blockquote", "Blockquote"],
["code", "Code Text"],
["li", "List item"],
["a", "Link"],
["span", ""],
Expand Down
3 changes: 2 additions & 1 deletion packages/html-data/bin/aria.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { aria } from "aria-query";
import { mkdir, writeFile } from "node:fs/promises";
import {
coreMetas,
createScope,
elementComponent,
Prop,
Expand Down Expand Up @@ -152,12 +153,12 @@ await writeFile(
generateWebstudioComponent({
name: "Page",
scope: createScope(),
metas: new Map(Object.entries(coreMetas)),
instances,
props,
dataSources: new Map(),
rootInstanceId: instance.id,
classesMap: new Map(),
parameters: [],
metas: new Map(),
}) + "export { Page }"
);
6 changes: 5 additions & 1 deletion packages/html-data/bin/attributes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { mkdir, writeFile } from "node:fs/promises";
import {
coreMetas,
createScope,
elementComponent,
type Instance,
Expand Down Expand Up @@ -54,6 +55,9 @@ const overrides: Record<
target: { required: true },
download: { type: "boolean", required: true },
},
blockquote: {
cite: { required: true },
},
form: {
action: { required: true },
method: { required: true },
Expand Down Expand Up @@ -263,13 +267,13 @@ await writeFile(
generateWebstudioComponent({
name: "Page",
scope: createScope(),
metas: new Map(Object.entries(coreMetas)),
instances,
props,
dataSources: new Map(),
rootInstanceId: body.id,
classesMap: new Map(),
parameters: [],
metas: new Map(),
}) + "export { Page }"
);

Expand Down
3 changes: 3 additions & 0 deletions packages/html-data/src/__generated__/attributes.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions packages/sdk-components-react/src/blockquote.template.tsx

This file was deleted.

4 changes: 0 additions & 4 deletions packages/sdk-components-react/src/code-text.ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,13 @@ const presetStyle = {
} satisfies PresetStyle<typeof defaultTag>;

export const meta: WsComponentMeta = {
category: "general",
description:
"Use this component when you want to display code as text on the page.",
icon: BracesIcon,
contentModel: {
category: "instance",
children: [],
},
states: defaultStates,
presetStyle,
order: 5,
initialProps: ["id", "class", "lang", "code"],
props: {
...props,
Expand Down
9 changes: 0 additions & 9 deletions packages/sdk-components-react/src/heading.template.tsx

This file was deleted.

8 changes: 0 additions & 8 deletions packages/sdk-components-react/src/list-item.template.tsx

This file was deleted.

20 changes: 0 additions & 20 deletions packages/sdk-components-react/src/list.template.tsx

This file was deleted.

8 changes: 0 additions & 8 deletions packages/sdk-components-react/src/paragraph.template.tsx

This file was deleted.

5 changes: 0 additions & 5 deletions packages/sdk-components-react/src/separator.ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import type { defaultTag } from "./separator";
const presetStyle = {
hr: [
...hr,

{
property: "height",
value: { type: "keyword", value: "1px" },
Expand Down Expand Up @@ -39,12 +38,8 @@ const presetStyle = {
} satisfies PresetStyle<typeof defaultTag>;

export const meta: WsComponentMeta = {
category: "general",
description:
"Used to visually divide sections of content, helping to improve readability and organization within a webpage.",
states: defaultStates,
presetStyle,
order: 3,
initialProps: ["id", "class"],
props,
};
6 changes: 0 additions & 6 deletions packages/sdk-components-react/src/templates.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
export { meta as ContentEmbed } from "./content-embed.template";
export { meta as MarkdownEmbed } from "./markdown-embed.template";
export { meta as Text } from "./text.template";
export { meta as Heading } from "./heading.template";
export { meta as Paragraph } from "./paragraph.template";
export { meta as Link } from "./link.template";
export { meta as Button } from "./button.template";
export { meta as Form } from "./webhook-form.template";
export { meta as Blockquote } from "./blockquote.template";
export { meta as List } from "./list.template";
export { meta as ListItem } from "./list-item.template";
export { meta as Label } from "./label.template";
export { meta as RadioButton } from "./radio-button.template";
export { meta as Checkbox } from "./checkbox.template";
Expand Down
9 changes: 0 additions & 9 deletions packages/sdk-components-react/src/text.template.tsx

This file was deleted.

Loading