diff --git a/_src /atoms/tab/Tab.spec.js b/_src /atoms/tab/Tab.spec.js deleted file mode 100644 index 8acbb04c0..000000000 --- a/_src /atoms/tab/Tab.spec.js +++ /dev/null @@ -1,43 +0,0 @@ -import { mount } from '@vue/test-utils' -import ATab from './Tab.vue' - -describe('Tab', () => { - it('has default structure', () => { - const wrapper = mount(ATab, { - propsData: { - name: 'Tab' - } - }) - - expect(wrapper.is('div')).toBe(true) - expect(wrapper.attributes().role).toBeDefined() - expect(wrapper.attributes().role).toEqual('tabpanel') - expect(wrapper.attributes('data-tab')).toBeDefined() - }) - - it('renders slot text when passed', () => { - const wrapper = mount(ATab, { - slots: { - default: 'Tab default text' - }, - propsData: { - name: 'Tab' - } - }) - - expect(wrapper.find('div > span').exists()).toBe(true) - expect(wrapper.find('div > span').text()).toEqual('Tab default text') - }) - - it('has correct id attribute', () => { - const wrapper = mount(ATab, { - propsData: { - name: 'Sample' - } - }) - - expect(wrapper.props().name).toBe('Sample') - expect(wrapper.attributes().id).toBeDefined() - expect(wrapper.attributes().id).toEqual('sample-tab') - }) -}) diff --git a/_src /molecules/tabs/Tabs.html b/_src /molecules/tabs/Tabs.html deleted file mode 100644 index 7da8bb083..000000000 --- a/_src /molecules/tabs/Tabs.html +++ /dev/null @@ -1,39 +0,0 @@ -
- -
- - -
-
diff --git a/_src /molecules/tabs/Tabs.js b/_src /molecules/tabs/Tabs.js deleted file mode 100644 index c03be6b9f..000000000 --- a/_src /molecules/tabs/Tabs.js +++ /dev/null @@ -1,71 +0,0 @@ -import KeyCodes from '../../utils/key-codes' - -// @vue/component - -export default { - data () { - return { - tabs: null, - activeFocusedTab: 0 - } - }, - computed: { - tabsChildren () { - return this.$children.filter(child => { - return child.$el.dataset.tab - }) - } - }, - mounted () { - this.tabs = this.tabsChildren - }, - methods: { - selectTab (selectedTab) { - this.$emit('click', selectedTab.name) - this.tabs.forEach(tab => { - if (selectedTab === this.activeFocusedTab) { - tab.isActive = tab.name === this.tabs[this.activeFocusedTab].name - } else { - tab.isActive = tab.name === selectedTab.name - } - }) - }, - focus (el) { - this.$refs[el][0].focus() - }, - onKeydown (e) { - const key = e.keyCode - - if (key === KeyCodes.TAB) { - e.preventDefault() - e.stopPropagation() - this.$refs.content.focus() - } else if ( - (key === KeyCodes.LEFT || - key === KeyCodes.UP || - key === KeyCodes.HOME) && - this.activeFocusedTab > 0 - ) { - if (key === KeyCodes.HOME) { - this.focus('button_0') - } else { - this.activeFocusedTab = this.activeFocusedTab - 1 - this.focus('button_' + this.activeFocusedTab) - } - } else if ( - (key === KeyCodes.RIGHT || - key === KeyCodes.DOWN || - key === KeyCodes.END) && - this.activeFocusedTab < this.tabs.length - 1 - ) { - if (key === KeyCodes.END) { - this.focus('button_' + (this.tabs.length - 1)) - } else { - this.activeFocusedTab = this.activeFocusedTab + 1 - this.focus('button_' + this.activeFocusedTab) - } - } - this.selectTab(this.activeFocusedTab) - } - } -} diff --git a/_src /molecules/tabs/Tabs.scss b/_src /molecules/tabs/Tabs.scss deleted file mode 100644 index 4f67175c1..000000000 --- a/_src /molecules/tabs/Tabs.scss +++ /dev/null @@ -1,59 +0,0 @@ -@import '../../../assets/styles/_globals.scss'; - -// common -$tabs__border-width : 8px !default; -$tabs__outline-focus : $blue solid 1px !default; - -// button -$tabs__button-padding : $spacer--medium !default; -$tabs__button-border : $tabs__border-width solid $gray-lightest !default; -$tabs__button-border--active : $tabs__border-width solid $color-primary !default; -$tabs__button-color : $gray !default; -$tabs__button-color--active : $gray-darker !default; -$tabs__button-font-weight : $font-weight-bold !default; -$tabs__button-background : $bg-color-base !default; -$tabs__button-background--active: $gray-lightest !default; - -// content -$tabs__content-padding : $spacer--medium 0 !default; -$tabs__content-padding\@large : $spacer--large $spacer--extra-large !default; - -.a-tabs { - display: flex; - flex-wrap: wrap; - - &__nav-button { - flex: 1; - padding: $tabs__button-padding; - color: $tabs__button-color; - font-weight: $tabs__button-font-weight; - background: $tabs__button-background; - border: none; - border-bottom: $tabs__button-border; - cursor: pointer; - - &--active { - color: $tabs__button-color--active; - background-color: $tabs__button-background--active; - border-bottom: $tabs__button-border--active; - } - - &:focus { - z-index: 1; - outline: $tabs__outline-focus; - } - } - - &__content { - flex: 100%; - padding: $tabs__content-padding; - - &:focus { - outline: $tabs__outline-focus; - } - - @include mq($screen-l) { - padding: $tabs__content-padding\@large; - } - } -} diff --git a/_src /molecules/tabs/Tabs.spec.js b/_src /molecules/tabs/Tabs.spec.js deleted file mode 100644 index eece5f2cc..000000000 --- a/_src /molecules/tabs/Tabs.spec.js +++ /dev/null @@ -1,59 +0,0 @@ -import Vue from 'vue' -import { mount } from '@vue/test-utils' -import ATabs from './Tabs.vue' -import ATab from '../../atoms/tab/Tab.vue' - -describe('Tabs', () => { - it('has default structure', () => { - const wrapper = mount(ATabs) - - expect(wrapper.is('div')).toBe(true) - expect(wrapper.classes()).toContain('a-tabs') - expect(wrapper.classes().length).toBe(1) - }) - - it('renders slot content when passed', () => { - const App = Vue.extend({ - render (h) { - return h(ATabs, {}, [ - h(ATab, { props: { name: 'First' } }, 'First content'), - h(ATab, { props: { name: 'Second' } }, 'Second content') - ]) - } - }) - const wrapper = mount(App) - - expect(wrapper.find('#first-tab-trigger').text()).toEqual('First') - expect(wrapper.find('#first-tab').text()).toEqual('First content') - expect(wrapper.find('#second-tab-trigger').text()).toEqual('Second') - expect(wrapper.find('#second-tab').text()).toEqual('Second content') - }) - - it('switches between tabs', () => { - const App = Vue.extend({ - render (h) { - return h(ATabs, {}, [ - h(ATab, { props: { name: 'First' } }, 'First content'), - h(ATab, { props: { name: 'Second' } }, 'Second content') - ]) - } - }) - const wrapper = mount(App) - const firstTrigger = wrapper.find('#first-tab-trigger') - const secondTrigger = wrapper.find('#second-tab-trigger') - const firstContent = wrapper.find('#first-tab') - const secondContent = wrapper.find('#second-tab') - - firstTrigger.trigger('click') - expect(firstTrigger.attributes('aria-selected')).toEqual('true') - expect(firstContent.isVisible()).toBe(true) - expect(secondTrigger.attributes('aria-selected')).toEqual('false') - expect(secondContent.isVisible()).toBe(false) - - secondTrigger.trigger('click') - expect(firstTrigger.attributes('aria-selected')).toEqual('false') - expect(firstContent.isVisible()).toBe(false) - expect(secondTrigger.attributes('aria-selected')).toEqual('true') - expect(secondContent.isVisible()).toBe(true) - }) -}) diff --git a/_src /molecules/tabs/Tabs.stories.js b/_src /molecules/tabs/Tabs.stories.js deleted file mode 100644 index de182b71f..000000000 --- a/_src /molecules/tabs/Tabs.stories.js +++ /dev/null @@ -1,91 +0,0 @@ -import { storiesOf } from '@storybook/vue' -import { action } from '@storybook/addon-actions' - -import ATabs from './Tabs.vue' -import ATab from './../../atoms/tab/Tab.vue' -import AButton from './../../atoms/button/Button.vue' -import AParagraph from './../../atoms/paragraph/Paragraph.vue' -import AIcon from './../../atoms/icon/Icon.vue' -import AIconStarBorder from './../../atoms/icon/templates/IconStarBorder.vue' - -storiesOf('Molecules/Tabs', module) - .addParameters({ info: true }) - .add('Default', () => ({ - components: { - ATabs, - ATab, - AParagraph - }, - methods: { - tabClick: action('Clicked tab') - }, - template: ` - - - - Toe in voluptate velit esse cillum dolore eu fugiat nulla pariatur. - - - - - Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. - - - - - Sed do eiusmod tempor incididunt ut labo. Ut enim ad minim veniam, re et dolore magna aliqua. quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. - - - - ` - })) - .add('With slot', () => ({ - components: { - ATabs, - ATab, - AButton, - AParagraph, - AIcon, - AIconStarBorder - }, - methods: { - tabClick: action('Clicked tab') - }, - template: ` - - - - - Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. - - - - - Alpaca Button - - - - - Sed do eiusmod tempor incididunt ut labo. Ut enim ad minim veniam, re et dolore magna aliqua. quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. - - - - ` - })) diff --git a/_src /molecules/tabs/Tabs.vue b/_src /molecules/tabs/Tabs.vue deleted file mode 100644 index b2f3a7786..000000000 --- a/_src /molecules/tabs/Tabs.vue +++ /dev/null @@ -1,14 +0,0 @@ -