From f7f7180437c8849c98e984eb5e75b2eed40c6aae Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 30 Jun 2021 16:33:35 +0100 Subject: [PATCH] Add spectrum card component --- .../bindings/DrawerBindableCombobox.svelte | 63 +++++------ .../design/AppPreview/componentStructure.json | 9 +- .../ComponentSettingsSection.svelte | 2 + .../FilterEditor/FilterEditor.svelte | 2 +- .../PropertyControls/URLSelect.svelte | 12 +++ packages/standard-components/manifest.json | 17 +-- .../standard-components/src/CardStat.svelte | 9 +- packages/standard-components/src/Link.svelte | 4 + .../src/SpectrumCard.svelte | 102 ++++++++++++++---- 9 files changed, 157 insertions(+), 63 deletions(-) diff --git a/packages/builder/src/components/common/bindings/DrawerBindableCombobox.svelte b/packages/builder/src/components/common/bindings/DrawerBindableCombobox.svelte index a1aa12090a..38f8693f51 100644 --- a/packages/builder/src/components/common/bindings/DrawerBindableCombobox.svelte +++ b/packages/builder/src/components/common/bindings/DrawerBindableCombobox.svelte @@ -14,6 +14,7 @@ export let placeholder export let label export let disabled = false + export let options const dispatch = createEventDispatcher() let bindingDrawer @@ -31,12 +32,13 @@
- onChange(event.detail)} {placeholder} + {options} /> {#if !disabled}
@@ -60,37 +62,36 @@ diff --git a/packages/builder/src/components/design/AppPreview/componentStructure.json b/packages/builder/src/components/design/AppPreview/componentStructure.json index 65ff6f262a..81962cd849 100644 --- a/packages/builder/src/components/design/AppPreview/componentStructure.json +++ b/packages/builder/src/components/design/AppPreview/componentStructure.json @@ -5,7 +5,6 @@ "table", "repeater", "button", - "spectrumcard", { "name": "Form", "icon": "Form", @@ -24,6 +23,14 @@ "daterangepicker" ] }, + { + "name": "Card", + "icon": "Card", + "children": [ + "spectrumcard", + "cardstat" + ] + }, { "name": "Chart", "icon": "GraphBarVertical", diff --git a/packages/builder/src/components/design/PropertiesPanel/ComponentSettingsSection.svelte b/packages/builder/src/components/design/PropertiesPanel/ComponentSettingsSection.svelte index 7bee9615bf..9139e4f6a2 100644 --- a/packages/builder/src/components/design/PropertiesPanel/ComponentSettingsSection.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/ComponentSettingsSection.svelte @@ -26,6 +26,7 @@ import RelationshipFieldSelect from "./PropertyControls/RelationshipFieldSelect.svelte" import ResetFieldsButton from "./PropertyControls/ResetFieldsButton.svelte" import ColorPicker from "./PropertyControls/ColorPicker.svelte" + import URLSelect from "./PropertyControls/URLSelect.svelte" export let componentDefinition export let componentInstance @@ -61,6 +62,7 @@ section: SectionSelect, navigation: NavigationEditor, filter: FilterEditor, + url: URLSelect, "field/string": StringFieldSelect, "field/number": NumberFieldSelect, "field/options": OptionsFieldSelect, diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/FilterEditor/FilterEditor.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/FilterEditor/FilterEditor.svelte index eee8fb113c..2a86afbf9a 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/FilterEditor/FilterEditor.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/FilterEditor/FilterEditor.svelte @@ -47,7 +47,7 @@ } -Define Filters +Define filters diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/URLSelect.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/URLSelect.svelte index e69de29bb2..5a19c1add3 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/URLSelect.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/URLSelect.svelte @@ -0,0 +1,12 @@ + + + diff --git a/packages/standard-components/manifest.json b/packages/standard-components/manifest.json index a8684edefd..e46b1580cc 100644 --- a/packages/standard-components/manifest.json +++ b/packages/standard-components/manifest.json @@ -878,7 +878,7 @@ "key": "text" }, { - "type": "text", + "type": "url", "label": "URL", "key": "url", "placeholder": "/screen" @@ -2085,7 +2085,7 @@ ] }, "spectrumcard": { - "name": "Card (Spectrum)", + "name": "Card", "icon": "Card", "styles": ["size"], "settings": [ @@ -2101,18 +2101,23 @@ }, { "type": "text", - "key": "footer", - "label": "Footer" + "key": "description", + "label": "Description" }, { "type": "text", "key": "imageURL", "label": "Image URL" }, + { + "type": "url", + "key": "linkURL", + "label": "Link URL" + }, { "type": "boolean", - "key": "quiet", - "label": "Quiet" + "key": "horizontal", + "label": "Horizontal" } ] } diff --git a/packages/standard-components/src/CardStat.svelte b/packages/standard-components/src/CardStat.svelte index 3b2fe12ea4..71d5dae66c 100644 --- a/packages/standard-components/src/CardStat.svelte +++ b/packages/standard-components/src/CardStat.svelte @@ -20,14 +20,13 @@ .container { min-width: 260px; width: max-content; - border: 1px solid var(--grey-3); + border: 1px solid var(--spectrum-global-color-gray-300); border-radius: 0.3rem; - color: var(--blue); } .title { font-size: 0.85rem; - color: #9e9e9e; + color: var(--spectrum-global-color-gray-600); font-weight: 600; margin: 1rem 1.5rem 0.5rem 1.5rem; white-space: pre-wrap; @@ -37,14 +36,14 @@ font-size: 2rem; font-weight: 600; margin: 0 1.5rem 1.5rem 1.5rem; - color: inherit; + color: var(--spectrum-global-color-blue-600); white-space: pre-wrap; } .label { font-size: 0.85rem; font-weight: 400; - color: #9e9e9e; + color: var(--spectrum-global-color-gray-600); margin: 1rem 1.5rem; white-space: pre-wrap; } diff --git a/packages/standard-components/src/Link.svelte b/packages/standard-components/src/Link.svelte index 93cac2e309..c94ab6db64 100644 --- a/packages/standard-components/src/Link.svelte +++ b/packages/standard-components/src/Link.svelte @@ -67,6 +67,10 @@ color: var(--spectrum-alias-text-color); display: inline-block; white-space: pre-wrap; + transition: color 130ms ease-in-out; + } + a:hover { + color: var(--spectrum-global-color-blue-600); } .placeholder { font-style: italic; diff --git a/packages/standard-components/src/SpectrumCard.svelte b/packages/standard-components/src/SpectrumCard.svelte index 74bee59bad..21adb795fa 100644 --- a/packages/standard-components/src/SpectrumCard.svelte +++ b/packages/standard-components/src/SpectrumCard.svelte @@ -4,20 +4,23 @@ export let title export let subtitle - export let footer + export let description export let imageURL - export let quiet + export let linkURL + export let horizontal - const { styleable } = getContext("sdk") + const { styleable, linkable } = getContext("sdk") const component = getContext("component") + + $: external = linkURL && !linkURL.startsWith("/")
{#if imageURL}
{/if} -
-
-
- {title || "Card Title"} -
-
- {#if subtitle} -
+
+
+
- {subtitle} + {#if linkURL} + {#if external} + {title || "Card Title"} + {:else} + {title || "Card Title"} + {/if} + {:else} + {title || "Card Title"} + {/if}
+ {#if subtitle} +
+
+ {subtitle} +
+
+ {/if} +
+ {#if description} + {/if}
- {#if footer} - - {/if}