Add sprectrum theme compatibility to autoscreens form text

This commit is contained in:
Andrew Kingston 2021-02-09 14:01:54 +00:00
parent 9054e764e0
commit 1deeb2ac3e
3 changed files with 20 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import {
makeSaveButton, makeSaveButton,
makeTableFormComponents, makeTableFormComponents,
makeMainForm, makeMainForm,
spectrumColor,
} from "./utils/commonComponents" } from "./utils/commonComponents"
export default function(tables) { export default function(tables) {
@ -52,6 +53,7 @@ function generateTitleContainer(table, title, formId) {
background: "transparent", background: "transparent",
color: "#4285f4", color: "#4285f4",
}) })
.customStyle(spectrumColor(700))
.text("Delete") .text("Delete")
.customProps({ .customProps({
className: "", className: "",

View File

@ -29,6 +29,11 @@ export class Component extends BaseStructure {
return this return this
} }
customStyle(styling) {
this._json._styles.custom = styling
return this
}
instanceName(name) { instanceName(name) {
this._json._instanceName = name this._json._instanceName = name
return this return this

View File

@ -3,6 +3,15 @@ import { Component } from "./Component"
import { rowListUrl } from "../rowListScreen" import { rowListUrl } from "../rowListScreen"
import { backendUiStore } from "builderStore" import { backendUiStore } from "builderStore"
export function spectrumColor(number) {
// Acorn throws a parsing error in this file if the word g-l-o-b-a-l is found
// (without dashes - I can't even type it in a comment).
// God knows why. It seems to think optional chaining further down the
// file is invalid if the word g-l-o-b-a-l is found - hence the reason this
// statement is split into parts.
return "color: var(--spectrum-glo" + `bal-color-gray-${number});`
}
export function makeLinkComponent(tableName) { export function makeLinkComponent(tableName) {
return new Component("@budibase/standard-components/link") return new Component("@budibase/standard-components/link")
.normalStyle({ .normalStyle({
@ -12,6 +21,7 @@ export function makeLinkComponent(tableName) {
.hoverStyle({ .hoverStyle({
color: "#4285f4", color: "#4285f4",
}) })
.customStyle(spectrumColor(700))
.text(tableName) .text(tableName)
.customProps({ .customProps({
url: `/${tableName.toLowerCase()}`, url: `/${tableName.toLowerCase()}`,
@ -52,6 +62,7 @@ export function makeBreadcrumbContainer(tableName, text, capitalise = false) {
"margin-right": "4px", "margin-right": "4px",
"margin-left": "4px", "margin-left": "4px",
}) })
.customStyle(spectrumColor(700))
.text(">") .text(">")
.instanceName("Arrow") .instanceName("Arrow")
@ -64,6 +75,7 @@ export function makeBreadcrumbContainer(tableName, text, capitalise = false) {
const identifierText = new Component("@budibase/standard-components/text") const identifierText = new Component("@budibase/standard-components/text")
.type("none") .type("none")
.normalStyle(textStyling) .normalStyle(textStyling)
.customStyle(spectrumColor(700))
.text(text) .text(text)
.instanceName("Identifier") .instanceName("Identifier")
@ -132,6 +144,7 @@ export function makeTitleContainer(title) {
"margin-left": "0px", "margin-left": "0px",
flex: "1 1 auto", flex: "1 1 auto",
}) })
.customStyle(spectrumColor(900))
.type("h3") .type("h3")
.instanceName("Title") .instanceName("Title")
.text(title) .text(title)