Skip to content

Commit

Permalink
Merge branch 'feature/test-image' into feature/dependencies-image
Browse files Browse the repository at this point in the history
  • Loading branch information
adrinr committed Jan 23, 2023
2 parents a90a1fd + 286e6f4 commit dbdc3e8
Show file tree
Hide file tree
Showing 44 changed files with 2,083 additions and 366 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.2.12-alpha.32",
"version": "2.2.12-alpha.34",
"npmClient": "yarn",
"packages": [
"packages/*"
Expand Down
4 changes: 2 additions & 2 deletions packages/backend-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@budibase/backend-core",
"version": "2.2.12-alpha.32",
"version": "2.2.12-alpha.34",
"description": "Budibase backend core libraries used in server and worker",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
Expand All @@ -23,7 +23,7 @@
},
"dependencies": {
"@budibase/nano": "10.1.1",
"@budibase/types": "2.2.12-alpha.32",
"@budibase/types": "2.2.12-alpha.34",
"@shopify/jest-koa-mocks": "5.0.1",
"@techpass/passport-openidconnect": "0.3.2",
"aws-cloudfront-sign": "2.2.0",
Expand Down
5 changes: 3 additions & 2 deletions packages/bbui/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@budibase/bbui",
"description": "A UI solution used in the different Budibase projects.",
"version": "2.2.12-alpha.32",
"version": "2.2.12-alpha.34",
"license": "MPL-2.0",
"svelte": "src/index.js",
"module": "dist/bbui.es.js",
Expand Down Expand Up @@ -38,7 +38,8 @@
],
"dependencies": {
"@adobe/spectrum-css-workflow-icons": "1.2.1",
"@budibase/string-templates": "2.2.12-alpha.32",
"@budibase/string-templates": "2.2.12-alpha.34",
"@spectrum-css/accordion": "3.0.24",
"@spectrum-css/actionbutton": "1.0.1",
"@spectrum-css/actiongroup": "1.0.1",
"@spectrum-css/avatar": "3.0.2",
Expand Down
58 changes: 58 additions & 0 deletions packages/bbui/src/Accordion/Accordion.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<script>
import "@spectrum-css/accordion"
export let itemName
export let initialOpen
export let header
let isOpen
function getOpenClass(isOpen) {
if (isOpen === undefined) {
isOpen = initialOpen
}
return isOpen ? "is-open" : ""
}
</script>

<div class="spectrum-Accordion" role={itemName}>
<div class="spectrum-Accordion-item {getOpenClass(isOpen)}">
<h3 class="spectrum-Accordion-itemHeading">
<button
class="spectrum-Accordion-itemHeader"
type="button"
on:click={() => (isOpen = !isOpen)}
>
{header}
</button>
<svg
class="spectrum-Icon spectrum-UIIcon-ChevronRight100 spectrum-Accordion-itemIndicator"
focusable="false"
aria-hidden="true"
>
<use xlink:href="#spectrum-css-icon-Chevron100" />
</svg>
</h3>
<div class="spectrum-Accordion-itemContent" role={itemName}>
<slot />
</div>
</div>
</div>

<style>
.spectrum-Accordion {
margin-left: -20px;
}
.spectrum-Accordion-item {
border: none;
}
.spectrum-Accordion-itemContent {
width: 97%;
padding-left: 30px;
}
.spectrum-Accordion-itemHeader {
text-transform: none;
font-weight: bold;
font-size: 0.875rem;
}
</style>
1 change: 1 addition & 0 deletions packages/bbui/src/ActionButton/ActionButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
}
.is-selected:not(.spectrum-ActionButton--emphasized) {
background: var(--spectrum-global-color-gray-300);
border-color: var(--spectrum-global-color-gray-700);
}
.noPadding {
padding: 0;
Expand Down
29 changes: 29 additions & 0 deletions packages/bbui/src/FancyForm/FancyButton.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<script>
import Icon from "../Icon/Icon.svelte"
import FancyField from "./FancyField.svelte"
export let icon
export let disabled
</script>

<FancyField on:click clickable {disabled}>
{#if icon}
{#if icon.includes("/")}
<img src={icon} alt="button" />
{:else}
<Icon name={icon} />
{/if}
{/if}
<div>
<slot />
</div>
</FancyField>

<style>
img {
width: 22px;
}
div {
font-size: var(--font-size-l);
}
</style>
70 changes: 70 additions & 0 deletions packages/bbui/src/FancyForm/FancyButtonRadio.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<script>
import { createEventDispatcher } from "svelte"
import FancyField from "./FancyField.svelte"
import FancyFieldLabel from "./FancyFieldLabel.svelte"
import ActionButton from "../ActionButton/ActionButton.svelte"
export let label
export let value
export let disabled = false
export let error = null
export let validate = null
export let options = []
export let getOptionLabel = option => extractProperty(option, "label")
export let getOptionValue = option => extractProperty(option, "value")
const dispatch = createEventDispatcher()
$: placeholder = !value
const extractProperty = (value, property) => {
if (value && typeof value === "object") {
return value[property]
}
return value
}
const onChange = newValue => {
dispatch("change", newValue)
value = newValue
if (validate) {
error = validate(newValue)
}
}
</script>

<FancyField {error} {value} {validate} {disabled} autoHeight>
{#if label}
<FancyFieldLabel placeholder={false}>{label}</FancyFieldLabel>
{/if}

<div class="options">
{#each options as option}
<ActionButton
selected={getOptionValue(option) === value}
on:click={() => onChange(getOptionValue(option))}
>
{getOptionLabel(option)}
</ActionButton>
{/each}
</div>
</FancyField>

<style>
.options {
margin-top: 34px;
margin-bottom: 14px;
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
gap: 6px;
flex-wrap: wrap;
}
.options :global(.spectrum-ActionButton) {
font-size: 15px;
line-height: 17px;
height: auto;
padding: 6px 10px;
}
</style>
53 changes: 53 additions & 0 deletions packages/bbui/src/FancyForm/FancyCheckbox.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<script>
import { createEventDispatcher } from "svelte"
import FancyField from "./FancyField.svelte"
import Checkbox from "../Form/Core/Checkbox.svelte"
export let value
export let text
export let disabled = false
export let error = null
export let validate = null
const dispatch = createEventDispatcher()
const onChange = () => {
const newValue = !value
dispatch("change", newValue)
value = newValue
if (validate) {
error = validate(newValue)
}
}
</script>

<FancyField {error} {value} {validate} {disabled} clickable on:click={onChange}>
<span>
<Checkbox {disabled} {value} />
</span>
<div class="text">
{#if text}
{text}
{/if}
<slot />
</div>
</FancyField>

<style>
span {
pointer-events: none;
}
.text {
font-size: 15px;
line-height: 17px;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
line-clamp: 2;
-webkit-box-orient: vertical;
}
.text > :global(*) {
font-size: inherit !important;
}
</style>
126 changes: 126 additions & 0 deletions packages/bbui/src/FancyForm/FancyField.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<script>
import Icon from "../Icon/Icon.svelte"
import { getContext, onMount } from "svelte"
import { slide } from "svelte/transition"
export let disabled = false
export let error = null
export let focused = false
export let clickable = false
export let validate
export let value
export let ref
export let autoHeight
const formContext = getContext("fancy-form")
const id = Math.random()
const API = {
validate: () => {
if (validate) {
error = validate(value)
}
return !error
},
}
onMount(() => {
if (formContext) {
formContext.registerField(id, API)
}
return () => {
if (formContext) {
formContext.unregisterField(id)
}
}
})
</script>

<div
bind:this={ref}
class="fancy-field"
class:error
class:disabled
class:focused
class:clickable
class:auto-height={autoHeight}
>
<div class="content" on:click>
<div class="field">
<slot />
</div>
{#if error}
<div class="error-icon">
<Icon name="Alert" />
</div>
{/if}
</div>
{#if error}
<div transition:slide|local={{ duration: 130 }} class="error-message">
{error}
</div>
{/if}
</div>

<style>
.fancy-field {
max-width: 400px;
background: var(--spectrum-global-color-gray-75);
border: 1px solid var(--spectrum-global-color-gray-300);
border-radius: 4px;
box-sizing: border-box;
transition: border-color 130ms ease-out, background 130ms ease-out,
background 130ms ease-out;
color: var(--spectrum-global-color-gray-800);
}
.fancy-field:hover {
border-color: var(--spectrum-global-color-gray-400);
}
.fancy-field.clickable:hover {
background: var(--spectrum-global-color-gray-200);
cursor: pointer;
}
.fancy-field.focused {
border-color: var(--spectrum-global-color-blue-400);
}
.fancy-field.error {
border-color: var(--spectrum-global-color-red-400);
}
.fancy-field.disabled {
background: var(--spectrum-global-color-gray-200);
color: var(--spectrum-global-color-gray-400);
border: 1px solid var(--spectrum-global-color-gray-300);
pointer-events: none;
}
.content {
position: relative;
height: 64px;
padding: 0 16px;
}
.fancy-field.auto-height .content {
height: auto;
}
.content,
.field {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
gap: 16px;
}
.field {
flex: 1 1 auto;
}
.error-message {
background: var(--spectrum-global-color-red-400);
color: white;
font-size: 14px;
padding: 6px 16px;
font-weight: 500;
}
.error-icon {
flex: 0 0 auto;
}
.error-icon :global(.spectrum-Icon) {
fill: var(--spectrum-global-color-red-400);
}
</style>
Loading

0 comments on commit dbdc3e8

Please sign in to comment.