Skip to content

Commit

Permalink
feat(#139): add layout component
Browse files Browse the repository at this point in the history
  • Loading branch information
Decipher committed Feb 18, 2024
1 parent 5c0ceae commit 4c88fff
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/components/Layout.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import CTLabel from './Label.vue'

export default {
title: 'CivicTheme/Atoms/Forms/Label',
component: CTLabel,
argTypes: {
size: {
options: ['extra-large', 'large', 'regular', 'small', 'extra-small'],
control: 'select'
},
theme: {
options: ['dark', 'light'],
control: 'select'
}
},
parameters: {
status: {
type: 'beta',
}
}
}

const Template = (args, { argTypes }) => {
return {
props: Object.keys(argTypes),
template: `<CTLabel v-bind="$props" v-on="$props">
<template v-if="$props.default">{{ $props.default }}</template>
</CTLabel>`,
}
}

export const Default = Template.bind({})
Default.storyName = 'Label'
Default.args = {
default: '[Default content slot]',
}
65 changes: 65 additions & 0 deletions src/components/Layout.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<template>
<main :class="`ct-layout ${themeClass}`" role="main">
<a id="main-content" tabindex="-1" />
<slot name="content_top" />

<div
class="ct-layout__inner"
:class="{
'container': container
}"
>
<div class="row">
<aside
v-if="hasSidebar"
class="ct-layout__sidebar"
:class="columnClasses.sidebar"
role="complementary"
>
<slot name="sidebar" />
</aside>

<section class="ct-layout__main" :class="columnClasses.main">
<div class="ct-layout--single-column">
<div class="ct-layout__content">
<slot />
</div>
</div>
</section>
</div>
</div>

<slot name="content_bottom" />
</main>
</template>

<script>
import ThemeMixin from '../mixins/theme'
export default {
mixins: [ThemeMixin],
props: {
columns: {
type: Object,
default: undefined
},
container: {
type: Boolean,
default: false
}
},
computed: {
columnClasses: ({ columns, hasSidebar }) => {
const colClasses = (o) => Object.entries(o).map(([key, value]) => `col-${key}-${value}`).join(' ')
return {
main: colClasses(columns?.main || hasSidebar ? { xss: 12, m: 8, 'm-offset': 1 } : { xss: 12 }),
sidebar: hasSidebar ? colClasses(columns?.sidebar || { xss: 12, m: 3 }) : undefined,
}
},
hasSidebar: ({ $slots }) => !!$slots?.sidebar
}
}
</script>

0 comments on commit 4c88fff

Please sign in to comment.