diff --git a/src/ui/src/components/core/base/BaseCollapseButton.vue b/src/ui/src/components/core/base/BaseCollapseButton.vue new file mode 100644 index 000000000..aaa712928 --- /dev/null +++ b/src/ui/src/components/core/base/BaseCollapseButton.vue @@ -0,0 +1,55 @@ + + + + + diff --git a/src/ui/src/components/core/layout/CoreColumn.vue b/src/ui/src/components/core/layout/CoreColumn.vue index bed519a72..7a38059d3 100644 --- a/src/ui/src/components/core/layout/CoreColumn.vue +++ b/src/ui/src/components/core/layout/CoreColumn.vue @@ -13,16 +13,12 @@

{{ fields.title.value }}

-
- -
+ direction="left-right" + />
@@ -31,6 +27,7 @@
diff --git a/src/ui/src/components/core/layout/CoreSidebar.vue b/src/ui/src/components/core/layout/CoreSidebar.vue index feede9019..81e6199ef 100644 --- a/src/ui/src/components/core/layout/CoreSidebar.vue +++ b/src/ui/src/components/core/layout/CoreSidebar.vue @@ -7,12 +7,7 @@ }" >
-
- -
+
@@ -33,7 +28,9 @@ import { buttonTextColor, buttonShadow, cssClasses, + startCollapsed, } from "@/renderer/sharedStyleFields"; +import BaseCollapseButton from "../base/BaseCollapseButton.vue"; const description = "A container component that organises its children in a sidebar. Its parent must be a Page component."; @@ -49,14 +46,8 @@ export default { category: "Layout", fields: { startCollapsed: { - name: "Start collapsed", - type: FieldType.Text, - category: FieldCategory.Style, - default: "no", - options: { - yes: "Yes", - no: "No", - }, + ...startCollapsed, + desc: undefined, }, sidebarBackgroundColor: { name: "Background", @@ -82,7 +73,6 @@ export default { - - diff --git a/src/ui/src/renderer/sharedStyleFields.ts b/src/ui/src/renderer/sharedStyleFields.ts index 4e9512001..e6f990810 100644 --- a/src/ui/src/renderer/sharedStyleFields.ts +++ b/src/ui/src/renderer/sharedStyleFields.ts @@ -1,27 +1,31 @@ -import { FieldCategory, FieldType } from "@/writerTypes"; +import { + FieldCategory, + FieldType, + WriterComponentDefinitionField, +} from "@/writerTypes"; -export const accentColor = { +export const accentColor: WriterComponentDefinitionField = { name: "Accent", type: FieldType.Color, category: FieldCategory.Style, applyStyleVariable: true, }; -export const primaryTextColor = { +export const primaryTextColor: WriterComponentDefinitionField = { name: "Primary text", type: FieldType.Color, category: FieldCategory.Style, applyStyleVariable: true, }; -export const secondaryTextColor = { +export const secondaryTextColor: WriterComponentDefinitionField = { name: "Secondary text", type: FieldType.Color, category: FieldCategory.Style, applyStyleVariable: true, }; -export const emptinessColor = { +export const emptinessColor: WriterComponentDefinitionField = { name: "Emptiness", desc: "Page background color", type: FieldType.Color, @@ -29,56 +33,56 @@ export const emptinessColor = { applyStyleVariable: true, }; -export const containerBackgroundColor = { +export const containerBackgroundColor: WriterComponentDefinitionField = { name: "Container background", type: FieldType.Color, category: FieldCategory.Style, applyStyleVariable: true, }; -export const containerShadow = { +export const containerShadow: WriterComponentDefinitionField = { name: "Container shadow", type: FieldType.Shadow, category: FieldCategory.Style, applyStyleVariable: true, }; -export const separatorColor = { +export const separatorColor: WriterComponentDefinitionField = { name: "Separator", type: FieldType.Color, category: FieldCategory.Style, applyStyleVariable: true, }; -export const buttonColor = { +export const buttonColor: WriterComponentDefinitionField = { name: "Button", type: FieldType.Color, category: FieldCategory.Style, applyStyleVariable: true, }; -export const buttonTextColor = { +export const buttonTextColor: WriterComponentDefinitionField = { name: "Button text", type: FieldType.Color, category: FieldCategory.Style, applyStyleVariable: true, }; -export const buttonShadow = { +export const buttonShadow: WriterComponentDefinitionField = { name: "Button shadow", type: FieldType.Shadow, category: FieldCategory.Style, applyStyleVariable: true, }; -export const cssClasses = { +export const cssClasses: WriterComponentDefinitionField = { name: "Custom CSS classes", type: FieldType.Text, category: FieldCategory.Style, desc: "CSS classes, separated by spaces. You can define classes in custom stylesheets.", }; -export const contentWidth = { +export const contentWidth: WriterComponentDefinitionField = { name: "Content width", type: FieldType.Width, default: "100%", @@ -86,23 +90,42 @@ export const contentWidth = { desc: "Configure content width using CSS units, e.g. 100px, 50%, 10vw, etc.", }; -export const contentHAlign = { +export const contentHAlign: WriterComponentDefinitionField = { name: "Content alignment (H)", type: FieldType.HAlign, default: "unset", category: FieldCategory.Style, }; -export const contentVAlign = { +export const contentVAlign: WriterComponentDefinitionField = { name: "Content alignment (V)", type: FieldType.VAlign, default: "unset", category: FieldCategory.Style, }; -export const contentPadding = { +export const contentPadding: WriterComponentDefinitionField = { name: "Padding", type: FieldType.Padding, default: "0", category: FieldCategory.Style, }; + +const yesNoOptions = { yes: "Yes", no: "No" }; + +export const isCollapsible: WriterComponentDefinitionField = { + name: "Collapsible", + default: "no", + type: FieldType.Text, + options: yesNoOptions, + category: FieldCategory.Style, +}; + +export const startCollapsed: WriterComponentDefinitionField = { + name: "Start collapsed", + type: FieldType.Text, + category: FieldCategory.Style, + default: "no", + options: yesNoOptions, + desc: "Only applied when the component is collapsible.", +}; diff --git a/src/ui/src/writerTypes.ts b/src/ui/src/writerTypes.ts index b611f6893..242b5e739 100644 --- a/src/ui/src/writerTypes.ts +++ b/src/ui/src/writerTypes.ts @@ -56,6 +56,28 @@ export type InstancePath = InstancePathItem[]; * Defines component structure and behaviour. Included in Component templates. */ +export type WriterComponentDefinitionField = { + /** Display name */ + name: string; + /** Initial value */ + init?: string; + /** Description */ + desc?: string; + /** Value used if the field is empty, e.g. "(No text)" */ + default?: string; + /** Which control (text, textarea, etc) to use if not the default for the type */ + control?: FieldControl; + options?: + | Record + | ((wf?: Core, componentId?: ComponentId) => Record); // List of values to be provided as autocomplete options + /** Data type for the field */ + type: FieldType; + /** Category (Layout, Content, etc) */ + category?: FieldCategory; + /** Use the value of this field as a CSS variable */ + applyStyleVariable?: boolean; +}; + export type WriterComponentDefinition = { name: string; // Display name for the component description: string; // Short description @@ -67,22 +89,7 @@ export type WriterComponentDefinition = { slot?: string; // In which slot component should render whgen "*" is used it will render in all slots fields?: Record< string, // Id for the field - { - name: string; // Display name - init?: string; // Initial value - desc?: string; // Description - default?: string; // Value used if the field is empty, e.g. "(No text)" - control?: FieldControl; // Which control (text, textarea, etc) to use if not the default for the type - options?: - | Record - | (( - wf?: Core, - componentId?: ComponentId, - ) => Record); // List of values to be provided as autocomplete options - type: FieldType; // Data type for the field - category?: FieldCategory; // Category (Layout, Content, etc) - applyStyleVariable?: boolean; // Use the value of this field as a CSS variable - } + WriterComponentDefinitionField >; events?: Record< string, // Event type