Skip to content

Commit

Permalink
feat(VsFooter) add vs-footer component
Browse files Browse the repository at this point in the history
  • Loading branch information
seaneez committed Jan 2, 2024
1 parent 3fcbed4 commit 6a74832
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/vlossom/src/components/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export type * from './vs-button';
export type * from './vs-container';
export type * from './vs-divider';
export type * from './vs-footer';
export type * from './vs-form';
export type * from './vs-input';
export type * from './vs-input-wrapper';
Expand Down
12 changes: 12 additions & 0 deletions packages/vlossom/src/components/vs-footer/VsFooter.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
footer {
align-items: center;
justify-content: center;
background-color: var(--vs-footer-backgroundColor, var(--vs-area-backgroundColor));
color: var(--vs-footer-fontColor, var(--vs-font-color));
display: flex;
flex-direction: column;
flex: 1 1 auto;
height: auto;
padding: var(--vs-footer-padding, 0.5rem 1rem);
width: var(--vs-footer-width, 100%);
}
58 changes: 58 additions & 0 deletions packages/vlossom/src/components/vs-footer/VsFooter.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<template>
<footer ref="vnFooterRef" :class="['vs-footer', `vs-${computedColorScheme}`]" :style="customProperties">
<slot />
</footer>
</template>

<script lang="ts">
import { PropType, computed, defineComponent, toRefs, watch, ref, nextTick, onMounted } from 'vue';
import { useColorScheme, useCustomStyle } from '@/composables';
import { ColorScheme, VsComponent } from '@/declaration/types';
interface FooterStyleSet {
backgroundColor: string;
color: string;
}
export type VsFooterStyleSet = Partial<FooterStyleSet>;
const name = VsComponent.VsFooter;
export default defineComponent({
name,
props: {
colorScheme: { type: String as PropType<ColorScheme> },
styleSet: { type: [String, Object] as PropType<string | VsFooterStyleSet>, default: '' },
},
setup(props) {
const { colorScheme, styleSet } = toRefs(props);
const { computedColorScheme } = useColorScheme(name, colorScheme);
const customProperties = useCustomStyle<VsFooterStyleSet>(name, styleSet);
const vnFooterRef = ref<HTMLElement | null>(null);
// watch(
// height,
// (value) => {
// nextTick(() => {
// const vnApp = document.querySelector<HTMLElement>('#vn-app');
// if (vnApp && vnFooterRef.value?.parentNode === vnApp) {
// vnApp.style.setProperty('--vn-footer-height', value);
// }
// });
// },
// { immediate: true }
// );
return {
computedColorScheme,
customProperties,
vnFooterRef,
};
},
});
</script>

<style lang="scss" scoped src="./VsFooter.scss" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { describe } from 'vitest';

describe('vs-footer', () => {});
12 changes: 12 additions & 0 deletions packages/vlossom/src/components/vs-footer/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { VsComponent } from '@/declaration/types';
import VsFooter from './VsFooter.vue';
import type { VsFooterStyleSet } from './VsFooter.vue';

type VsFooterInstance = InstanceType<typeof VsFooter>;

export type { VsFooterInstance, VsFooterStyleSet };

export default {
name: VsComponent.VsFooter,
component: VsFooter,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import type { Meta, StoryObj } from '@storybook/vue3';
import { colorScheme } from '@/storybook/args';
import VsFooter from './../VsFooter.vue';

const lorem = `Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum
.`;

const meta: Meta<typeof VsFooter> = {
title: 'Components/Layout Components/VsFooter',
component: VsFooter,
render: (args: any) => ({
components: { VsFooter },
setup() {
return { args, lorem };
},
template: '<vs-footer v-bind="args" style="height: 300px;"> This is Footer </vs-footer>',
// template: '<vs-footer v-bind="args" > <div>content1</div>{{ lorem }} <div>content2</div> </vs-footer>',
}),
tags: ['autodocs'],
argTypes: {
colorScheme,
},
};

export default meta;
type Story = StoryObj<typeof VsFooter>;

export const Default: Story = {};

export const ColorScheme: Story = {
render: () => ({
components: { VsFooter },
setup() {
const colorOptions = [...colorScheme.options];
return { colorOptions };
},
template: `
<div>
<vs-footer v-for="(color, index) in colorOptions" :key="index" :color-scheme="color"
:style="{marginBottom: '1rem'}"
>
This is Footer
</vs-footer>
</div>
`,
}),
};
3 changes: 3 additions & 0 deletions packages/vlossom/src/declaration/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type {
VsButtonStyleSet,
VsDividerStyleSet,
VsFooterStyleSet,
VsInputStyleSet,
VsPageStyleSet,
VsSectionStyleSet,
Expand All @@ -14,6 +15,7 @@ export enum VsComponent {
VsButton = 'VsButton',
VsContainer = 'VsContainer',
VsDivider = 'VsDivider',
VsFooter = 'VsFooter',
VsForm = 'VsForm',
VsInput = 'VsInput',
VsInputWrapper = 'VsInputWrapper',
Expand All @@ -33,6 +35,7 @@ export type GlobalColorScheme = { default?: ColorScheme } & { [key in VsComponen
export interface StyleSet {
VsButton?: { [key: string]: VsButtonStyleSet };
VsDivider?: { [key: string]: VsDividerStyleSet };
VsFooter?: { [key: string]: VsFooterStyleSet };
VsInput?: { [key: string]: VsInputStyleSet };
VsSection?: { [key: string]: VsSectionStyleSet };
VsNotice?: { [key: string]: VsNoticeStyleSet };
Expand Down

0 comments on commit 6a74832

Please sign in to comment.