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

66 lines
1.2 KiB
Svelte
Raw Normal View History

<script>
import { params, goto } from "@sveltech/routify"
import { store } from "builderStore"
2020-02-03 10:50:30 +01:00
const getPage = (s, name) => {
const props = s.pages[name]
return { name, props }
}
2020-02-03 10:50:30 +01:00
const pages = [
{
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.currentPageName)
store.setCurrentPage($params.page ? $params.page : "main")
2020-10-27 16:28:13 +01:00
const changePage = id => {
store.setCurrentPage(id)
$goto(`./${id}/page-layout`)
}
</script>
<div class="root">
2020-05-29 19:32:52 +02:00
{#each pages as { title, id }}
<button class:active={id === $params.page} on:click={() => changePage(id)}>
{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;
background: #ffffff;
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>