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

93 lines
1.6 KiB
Svelte
Raw Normal View History

<script>
import { params, goto } from "@sveltech/routify"
import { store } from "builderStore"
import getIcon from "components/common/icon"
import { CheckIcon } from "components/common/Icons"
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: "Main",
id: "main",
},
{
title: "Login",
id: "unauthenticated",
},
]
if (!$store.currentPageName)
store.setCurrentPage($params.page ? $params.page : "main")
const changePage = id => {
store.setCurrentPage(id)
$goto(`./${id}/page-layout`)
}
</script>
<div class="root">
2020-02-20 18:11:41 +01:00
<ul>
2020-02-03 10:50:30 +01:00
{#each pages as { title, id }}
2020-02-20 18:11:41 +01:00
<li>
<span class="icon">
{#if id === $params.page}
2020-02-20 18:11:41 +01:00
<CheckIcon />
{/if}
</span>
2020-02-20 18:11:41 +01:00
<button
class:active={id === $params.page}
on:click={() => changePage(id)}>
2020-02-20 18:11:41 +01:00
{title}
</button>
</li>
{/each}
</ul>
</div>
<style>
2020-02-03 10:50:30 +01:00
.root {
padding-bottom: 10px;
font-size: 0.9rem;
2020-03-24 11:56:48 +01:00
color: #000333;
2020-02-03 10:50:30 +01:00
font-weight: bold;
position: relative;
2020-02-20 18:11:41 +01:00
padding-left: 1.8rem;
2020-02-03 10:50:30 +01:00
}
2020-02-20 18:11:41 +01:00
ul {
2020-02-03 10:50:30 +01:00
margin: 0;
2020-02-20 18:11:41 +01:00
padding: 0;
list-style: none;
}
li {
margin: 0.5rem 0;
}
button {
margin: 0 0 0 6px;
padding: 0;
2020-02-03 10:50:30 +01:00
border: none;
2020-02-20 18:11:41 +01:00
font-family: Roboto;
2020-04-03 15:26:07 +02:00
font-size: 13px;
2020-02-20 18:11:41 +01:00
outline: none;
cursor: pointer;
2020-03-27 17:58:32 +01:00
background: rgba(0, 0, 0, 0);
2020-02-20 18:11:41 +01:00
}
.active {
font-weight: 500;
2020-02-03 10:50:30 +01:00
}
2020-02-20 18:11:41 +01:00
.icon {
display: inline-block;
width: 14px;
2020-03-24 11:56:48 +01:00
color: #000333;
2020-02-03 10:50:30 +01:00
}
</style>