mirror of
https://github.com/directus/directus.git
synced 2026-01-27 04:48:04 -05:00
Add divider component (#252)
This commit is contained in:
4
src/components/v-divider/index.ts
Normal file
4
src/components/v-divider/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import VDivider from './v-divider.vue';
|
||||
|
||||
export { VDivider };
|
||||
export default VDivider;
|
||||
26
src/components/v-divider/readme.md
Normal file
26
src/components/v-divider/readme.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# Divider
|
||||
|
||||
Divides content. Made to be used in `v-list` or `v-tabs` components.
|
||||
|
||||
## Usage
|
||||
|
||||
```html
|
||||
<v-divider />
|
||||
```
|
||||
|
||||
## Props
|
||||
| Prop | Description | Default |
|
||||
|------------|-----------------------------------------------------|---------|
|
||||
| `vertical` | Render the divider vertically | `false` |
|
||||
| `inset` | Insets the divider to align with the (list) content | `false` |
|
||||
|
||||
## Events
|
||||
n/a
|
||||
|
||||
## Slots
|
||||
n/a
|
||||
|
||||
## CSS Variables
|
||||
| Variable | Default |
|
||||
|---------------------|-------------------------------------|
|
||||
| `--v-divider-color` | `var(--foreground-color-tertiary)` |
|
||||
84
src/components/v-divider/v-divider.story.ts
Normal file
84
src/components/v-divider/v-divider.story.ts
Normal file
@@ -0,0 +1,84 @@
|
||||
import VDivider from './v-divider.vue';
|
||||
import readme from './readme.md';
|
||||
import withPadding from '../../../.storybook/decorators/with-padding';
|
||||
import { withKnobs, boolean } from '@storybook/addon-knobs';
|
||||
import { defineComponent } from '@vue/composition-api';
|
||||
import VList, {
|
||||
VListItem,
|
||||
VListItemContent,
|
||||
VListItemTitle,
|
||||
VListItemIcon,
|
||||
} from '@/components/v-list';
|
||||
import VIcon from '@/components/v-icon/';
|
||||
|
||||
export default {
|
||||
title: 'Components / Divider',
|
||||
parameters: {
|
||||
notes: readme,
|
||||
},
|
||||
decorators: [withPadding, withKnobs],
|
||||
};
|
||||
|
||||
export const basic = () =>
|
||||
defineComponent({
|
||||
components: { VDivider },
|
||||
props: {
|
||||
vertical: {
|
||||
default: boolean('Vertical', false),
|
||||
},
|
||||
inset: {
|
||||
default: boolean('Inset', false),
|
||||
},
|
||||
},
|
||||
template: `
|
||||
<v-divider :vertical="vertical" :inset="inset" />
|
||||
`,
|
||||
});
|
||||
|
||||
export const inList = () =>
|
||||
defineComponent({
|
||||
components: {
|
||||
VDivider,
|
||||
VList,
|
||||
VListItem,
|
||||
VListItemContent,
|
||||
VListItemIcon,
|
||||
VListItemTitle,
|
||||
VIcon,
|
||||
},
|
||||
props: {
|
||||
inset: {
|
||||
default: boolean('Inset', false),
|
||||
},
|
||||
},
|
||||
template: `
|
||||
<v-sheet style="max-width: 200px">
|
||||
<v-list>
|
||||
<v-list-item v-for="n in 3" @click="() => {}">
|
||||
<v-list-item-icon><v-icon name="box" /></v-list-item-icon />
|
||||
<v-list-item-content>
|
||||
<v-list-item-title>Item {{ n }}</v-list-item-title>
|
||||
</v-list-item-content>
|
||||
</v-list-item>
|
||||
|
||||
<v-divider :inset="inset" style="margin-top: 8px; margin-bottom: 8px;" />
|
||||
|
||||
<v-list-item v-for="n in 1" @click="() => {}">
|
||||
<v-list-item-icon><v-icon name="box" /></v-list-item-icon />
|
||||
<v-list-item-content>
|
||||
<v-list-item-title>Item {{ n + 3 }}</v-list-item-title>
|
||||
</v-list-item-content>
|
||||
</v-list-item>
|
||||
|
||||
<v-divider :inset="inset" style="margin-top: 8px; margin-bottom: 8px;" />
|
||||
|
||||
<v-list-item v-for="n in 3" @click="() => {}">
|
||||
<v-list-item-icon><v-icon name="box" /></v-list-item-icon />
|
||||
<v-list-item-content>
|
||||
<v-list-item-title>Item {{ n + 4 }}</v-list-item-title>
|
||||
</v-list-item-content>
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
</v-sheet>
|
||||
`,
|
||||
});
|
||||
14
src/components/v-divider/v-divider.test.ts
Normal file
14
src/components/v-divider/v-divider.test.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { shallowMount, createLocalVue } from '@vue/test-utils';
|
||||
import VueCompositionAPI from '@vue/composition-api';
|
||||
|
||||
import VDivider from './v-divider.vue';
|
||||
|
||||
const localVue = createLocalVue();
|
||||
localVue.use(VueCompositionAPI);
|
||||
|
||||
describe('Components / Divider', () => {
|
||||
it('Renders', () => {
|
||||
const component = shallowMount(VDivider, { localVue });
|
||||
expect(component.isVueInstance()).toBe(true);
|
||||
});
|
||||
});
|
||||
61
src/components/v-divider/v-divider.vue
Normal file
61
src/components/v-divider/v-divider.vue
Normal file
@@ -0,0 +1,61 @@
|
||||
<template>
|
||||
<hr
|
||||
class="v-divider"
|
||||
role="separator"
|
||||
:class="{ vertical, inset }"
|
||||
:aria-orientation="vertical ? 'vertical' : 'horizontal'"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from '@vue/composition-api';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
inset: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
vertical: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.v-divider {
|
||||
--v-divider-color: var(--foreground-color-tertiary);
|
||||
|
||||
display: block;
|
||||
flex-basis: 0px;
|
||||
flex-grow: 1;
|
||||
flex-shrink: 1;
|
||||
max-width: 100%;
|
||||
overflow: visible;
|
||||
border: solid;
|
||||
border-color: var(--v-divider-color);
|
||||
border-width: 2px 0 0 0;
|
||||
|
||||
&.inset:not(.vertical) {
|
||||
max-width: calc(100% - 52px);
|
||||
margin-left: 52px;
|
||||
}
|
||||
|
||||
&.vertical {
|
||||
display: inline-flex;
|
||||
align-self: stretch;
|
||||
width: 0px;
|
||||
max-width: 0px;
|
||||
height: inherit;
|
||||
border-width: 0 2px 0 0;
|
||||
|
||||
&.inset {
|
||||
min-height: 0;
|
||||
max-height: calc(100% - 16px);
|
||||
margin-top: 8px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user