budibase/packages/builder/src/components/userInterface/LayoutsList.svelte

65 lines
1.2 KiB
Svelte
Raw Normal View History

<script>
import { params, goto } from "@sveltech/routify"
import { store } from "builderStore"
2020-11-24 19:11:34 +01:00
const layouts = [
2020-02-03 10:50:30 +01:00
{
title: "Private",
2020-02-03 10:50:30 +01:00
id: "main",
},
{
title: "Public",
2020-02-03 10:50:30 +01:00
id: "unauthenticated",
},
]
if (!$store.currentAssetId) {
// refactor so the right layout is chosen
2020-12-02 18:07:30 +01:00
store.actions.layouts.select($params.layout)
}
2020-11-24 19:11:34 +01:00
const changeLayout = id => {
store.actions.layouts.select(id)
$goto(`./${id}/layout`)
}
</script>
<div class="root">
2020-11-24 19:11:34 +01:00
{#each layouts as { title, id }}
<button
class:active={id === $params.layout}
on:click={() => changeLayout(id)}>
2020-05-29 19:32:52 +02:00
{title}
</button>
{/each}
</div>
<style>
2020-02-03 10:50:30 +01:00
.root {
display: flex;
flex-direction: row;
2020-02-20 18:11:41 +01:00
}
button {
cursor: pointer;
2020-10-22 19:11:33 +02:00
padding: 0 var(--spacing-m);
height: 32px;
text-align: center;
2020-10-29 21:42:34 +01:00
background: var(--background);
color: var(--grey-7);
border-radius: 5px;
2020-10-22 19:11:33 +02:00
font-size: var(--font-size-xs);
font-weight: 500;
transition: all 0.3s;
text-rendering: optimizeLegibility;
border: none !important;
outline: none;
2020-10-22 19:11:33 +02:00
font-family: var(--font-sans);
2020-02-20 18:11:41 +01:00
}
.active {
background: var(--grey-2);
color: var(--ink);
2020-02-03 10:50:30 +01:00
}
</style>