Update list and detail autoscreens to be theme aware and use new designs

This commit is contained in:
Andrew Kingston 2021-07-05 10:20:20 +01:00
parent af8f616624
commit a3d1b959fc
4 changed files with 27 additions and 89 deletions

View File

@ -38,8 +38,6 @@ const createScreen = table => {
.instanceName("Form") .instanceName("Form")
.customProps({ .customProps({
actionType: "Create", actionType: "Create",
theme: "spectrum--lightest",
size: "spectrum--medium",
dataSource: { dataSource: {
label: table.name, label: table.name,
tableId: table._id, tableId: table._id,

View File

@ -26,36 +26,13 @@ export const ROW_DETAIL_TEMPLATE = "ROW_DETAIL_TEMPLATE"
export const rowDetailUrl = table => sanitizeUrl(`/${table.name}/:id`) export const rowDetailUrl = table => sanitizeUrl(`/${table.name}/:id`)
function generateTitleContainer(table, title, formId, repeaterId) { function generateTitleContainer(table, title, formId, repeaterId) {
// have to override style for this, its missing margin const saveButton = makeSaveButton(table, formId)
const saveButton = makeSaveButton(table, formId).normalStyle({
background: "#000000",
"border-width": "0",
"border-style": "None",
color: "#fff",
"font-weight": "600",
"font-size": "14px",
})
const deleteButton = new Component("@budibase/standard-components/button") const deleteButton = new Component("@budibase/standard-components/button")
.normalStyle({
background: "transparent",
"border-width": "0",
"border-style": "None",
color: "#9e9e9e",
"font-weight": "600",
"font-size": "14px",
"margin-right": "8px",
"margin-left": "16px",
})
.hoverStyle({
background: "transparent",
color: "#4285f4",
})
.customStyle(spectrumColor(700))
.text("Delete") .text("Delete")
.customProps({ .customProps({
className: "", type: "secondary",
disabled: false, quiet: true,
size: "M",
onClick: [ onClick: [
{ {
parameters: { parameters: {
@ -76,7 +53,19 @@ function generateTitleContainer(table, title, formId, repeaterId) {
}) })
.instanceName("Delete Button") .instanceName("Delete Button")
return makeTitleContainer(title).addChild(deleteButton).addChild(saveButton) const buttons = new Component("@budibase/standard-components/container")
.instanceName("Button Container")
.customProps({
direction: "row",
hAlign: "right",
vAlign: "middle",
size: "shrink",
gap: "M",
})
.addChild(deleteButton)
.addChild(saveButton)
return makeTitleContainer(title).addChild(buttons)
} }
const createScreen = table => { const createScreen = table => {

View File

@ -100,9 +100,6 @@ const createScreen = table => {
return new Screen() return new Screen()
.route(rowListUrl(table)) .route(rowListUrl(table))
.instanceName(`${table.name} - List`) .instanceName(`${table.name} - List`)
.normalStyle({
["padding-top"]: "32px",
})
.addChild(generateTitleContainer(table)) .addChild(generateTitleContainer(table))
.addChild(provider) .addChild(provider)
.json() .json()

View File

@ -8,23 +8,16 @@ export function spectrumColor(number) {
// God knows why. It seems to think optional chaining further down the // 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 // file is invalid if the word g-l-o-b-a-l is found - hence the reason this
// statement is split into parts. // statement is split into parts.
return "color: var(--spectrum-glo" + `bal-color-gray-${number});` return "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({
color: "#757575",
"text-transform": "capitalize",
})
.hoverStyle({
color: "#4285f4",
})
.customStyle(spectrumColor(700))
.text(tableName) .text(tableName)
.customProps({ .customProps({
url: `/${tableName.toLowerCase()}`, url: `/${tableName.toLowerCase()}`,
openInNewTab: false, openInNewTab: false,
color: spectrumColor(700),
size: "S", size: "S",
align: "left", align: "left",
}) })
@ -33,19 +26,12 @@ export function makeLinkComponent(tableName) {
export function makeMainForm() { export function makeMainForm() {
return new Component("@budibase/standard-components/form") return new Component("@budibase/standard-components/form")
.normalStyle({ .normalStyle({
width: "700px", width: "600px",
padding: "0px",
"border-radius": "0.5rem",
"box-shadow": "0 1px 2px 0 rgba(0, 0, 0, 0.05)",
"padding-top": "48px",
"padding-bottom": "48px",
"padding-right": "48px",
"padding-left": "48px",
}) })
.instanceName("Form") .instanceName("Form")
} }
export function makeBreadcrumbContainer(tableName, text, capitalise = false) { export function makeBreadcrumbContainer(tableName, text) {
const link = makeLinkComponent(tableName).instanceName("Back Link") const link = makeLinkComponent(tableName).instanceName("Back Link")
const arrowText = new Component("@budibase/standard-components/text") const arrowText = new Component("@budibase/standard-components/text")
@ -53,42 +39,27 @@ export function makeBreadcrumbContainer(tableName, text, capitalise = false) {
.normalStyle({ .normalStyle({
"margin-right": "4px", "margin-right": "4px",
"margin-left": "4px", "margin-left": "4px",
"margin-top": "0px",
"margin-bottom": "0px",
}) })
.customStyle(spectrumColor(700))
.text(">") .text(">")
.instanceName("Arrow") .instanceName("Arrow")
.customProps({ .customProps({
color: spectrumColor(700),
size: "S", size: "S",
align: "left", align: "left",
}) })
const textStyling = {
color: "#000000",
"margin-top": "0px",
"margin-bottom": "0px",
}
if (capitalise) {
textStyling["text-transform"] = "capitalize"
}
const identifierText = new Component("@budibase/standard-components/text") const identifierText = new Component("@budibase/standard-components/text")
.type("none")
.normalStyle(textStyling)
.customStyle(spectrumColor(700))
.text(text) .text(text)
.instanceName("Identifier") .instanceName("Identifier")
.customProps({ .customProps({
color: spectrumColor(700),
size: "S", size: "S",
align: "left", align: "left",
}) })
return new Component("@budibase/standard-components/container") return new Component("@budibase/standard-components/container")
.normalStyle({
"font-size": "14px",
color: "#757575",
})
.customProps({ .customProps({
gap: "N",
direction: "row", direction: "row",
hAlign: "left", hAlign: "left",
vAlign: "middle", vAlign: "middle",
@ -102,22 +73,10 @@ export function makeBreadcrumbContainer(tableName, text, capitalise = false) {
export function makeSaveButton(table, formId) { export function makeSaveButton(table, formId) {
return new Component("@budibase/standard-components/button") return new Component("@budibase/standard-components/button")
.normalStyle({
background: "#000000",
"border-width": "0",
"border-style": "None",
color: "#fff",
"font-weight": "600",
"font-size": "14px",
"margin-left": "16px",
})
.hoverStyle({
background: "#4285f4",
})
.text("Save") .text("Save")
.customProps({ .customProps({
className: "", type: "primary",
disabled: false, size: "M",
onClick: [ onClick: [
{ {
"##eventHandlerType": "Validate Form", "##eventHandlerType": "Validate Form",
@ -145,12 +104,6 @@ export function makeSaveButton(table, formId) {
export function makeTitleContainer(title) { export function makeTitleContainer(title) {
const heading = new Component("@budibase/standard-components/heading") const heading = new Component("@budibase/standard-components/heading")
.normalStyle({
margin: "0px",
flex: "1 1 auto",
})
.customStyle(spectrumColor(900))
.type("h2")
.instanceName("Title") .instanceName("Title")
.text(title) .text(title)
.customProps({ .customProps({
@ -168,6 +121,7 @@ export function makeTitleContainer(title) {
hAlign: "stretch", hAlign: "stretch",
vAlign: "middle", vAlign: "middle",
size: "shrink", size: "shrink",
gap: "M",
}) })
.instanceName("Title Container") .instanceName("Title Container")
.addChild(heading) .addChild(heading)