Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: tabs component #11

Merged
merged 2 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .eslintrc-auto-import.json
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,13 @@
"DEFAULT_POPPER_OPTIONS": true,
"formatCurrency": true,
"formatNumber": true,
"formatInteger": true
"formatInteger": true,
"onBeforeRouteLeave": true,
"onBeforeRouteUpdate": true,
"useLink": true,
"useRoute": true,
"useRouter": true,
"WritableComputedRef": true,
"assert": true
}
}
37 changes: 37 additions & 0 deletions example/cypress/e2e/tabs.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// https://docs.cypress.io/api/introduction/api.html

describe('Tabs', () => {
beforeEach(() => {
cy.visit('/tabs');
});

it('check for rendered tabs', () => {
cy.contains('h2[data-cy=tabs]', 'Tabs');

cy.get('[data-cy=wrapper-0]').as('wrapper');

cy.get('@wrapper')
.find('[data-cy=tabs]')
.find('[role=tablist]')
.as('tablist');

cy.get('@tablist').children().should('have.length', 6);
cy.get('@tablist')
.find('button:first-child')
.should('have.class', 'active-tab');
cy.get('@tablist').find('button:nth-child(2)').should('be.disabled');

cy.get('@wrapper').find('[data-cy=tab-items]').as('tabcontent');

cy.get('@tabcontent').should('have.text', 'Tab 1 Content');

// Click third tab
cy.get('@tablist').find('button:nth-child(3)').click();
cy.get('@tabcontent').should('have.text', 'Tab 3 Content');

// Click last tab should redirect to stepper page
cy.get('@tablist').find('a:last-child').click();

cy.url().should('contain', '/steppers');
});
});
1 change: 1 addition & 0 deletions example/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const navigation = ref([
{ to: { name: 'tooltips' }, title: 'Tooltips' },
{ to: { name: 'data-tables' }, title: 'Data Tables' },
{ to: { name: 'cards' }, title: 'Cards' },
{ to: { name: 'tabs' }, title: 'Tabs' },
],
},
]);
Expand Down
8 changes: 8 additions & 0 deletions example/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ import { PiniaVuePlugin, createPinia, setActivePinia } from 'pinia';
import {
RiAddFill,
RiAlertLine,
RiArrowDownSLine,
RiArrowLeftLine,
RiArrowLeftSLine,
RiArrowRightLine,
RiArrowRightSLine,
RiArrowUpSLine,
RiCheckboxCircleLine,
RiCloseFill,
RiErrorWarningLine,
Expand Down Expand Up @@ -35,6 +39,10 @@ Vue.use(RuiPlugin, {
RiCloseFill,
RiInformationLine,
RiErrorWarningLine,
RiArrowLeftSLine,
RiArrowRightSLine,
RiArrowUpSLine,
RiArrowDownSLine,
],
});

Expand Down
5 changes: 5 additions & 0 deletions example/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ const router = new VueRouter({
name: 'cards',
component: () => import('@/views/CardView.vue'),
},
{
path: '/tabs',
name: 'tabs',
component: () => import('@/views/TabView.vue'),
},
],
});

Expand Down
111 changes: 111 additions & 0 deletions example/src/views/TabView.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<script setup lang="ts">
import {
RuiCard,
RuiIcon,
RuiTab,
RuiTabItem,
RuiTabItems,
RuiTabs,
} from '@rotki/ui-library-compat';
import { ref } from 'vue';
import { type DataType } from '@/types';

type TabsData = DataType<typeof RuiTabs, string>;

const tabs = ref<TabsData[]>([
{
color: 'primary',
},
{
color: 'secondary',
},
{
color: 'error',
},
{
color: 'warning',
},
{
color: 'info',
},
{
color: 'success',
},
{
color: 'primary',
vertical: true,
},
{
color: 'secondary',
vertical: true,
},
{
color: 'error',
vertical: true,
},
{
color: 'warning',
vertical: true,
},
{
color: 'info',
vertical: true,
},
{
color: 'success',
vertical: true,
},
]);
</script>

<template>
<div>
<h2 class="text-h4 mb-6" data-cy="tabs">Tabs</h2>
<div
v-for="(data, i) in tabs"
:key="i"
class="flex mb-6 gap-x-6"
:class="data.vertical ? 'flex-row' : 'flex-col'"
:data-cy="`wrapper-${i}`"
>
<RuiTabs v-bind="data" v-model="data.modelValue" data-cy="tabs">
<template #default>
<RuiTab>
<template #prepend>
<RuiIcon name="add-fill" />
</template>
Tab 1
</RuiTab>
<RuiTab disabled>Tab 2</RuiTab>
<RuiTab>Tab 3</RuiTab>
<RuiTab>Tab 4</RuiTab>
<RuiTab>Tab 5</RuiTab>
<RuiTab link to="/steppers">Stepper View</RuiTab>
</template>
</RuiTabs>
<RuiTabItems v-model="data.modelValue" data-cy="tab-items">
<template #default>
<RuiTabItem>
<RuiCard>Tab 1 Content</RuiCard>
</RuiTabItem>
<RuiTabItem>
<RuiCard>Tab 2 Content</RuiCard>
</RuiTabItem>
<RuiTabItem>
<RuiCard>Tab 3 Content</RuiCard>
</RuiTabItem>
<RuiTabItem>
<RuiCard>Tab 4 Content</RuiCard>
</RuiTabItem>
<RuiTabItem>
<RuiCard>
Tab 5 Long Long Long Long Long Long Long Long Long Long Long Long
Long Long Long Long Long Long Long Long Long Long Long Long Long
Long Long Long Long Long Long Long Long Content
</RuiCard>
</RuiTabItem>
</template>
</RuiTabItems>
</div>
</div>
</template>
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@
"@vueuse/shared": ">10.0.0",
"vue": ">=2.7.14 <3"
},
"optionalDependencies": {
"vue-router": ">=3.6.5"
},
"devDependencies": {
"@babel/core": "7.22.9",
"@babel/types": "7.22.5",
Expand Down Expand Up @@ -145,6 +148,7 @@
"vitest": "0.34.1",
"vue": "2.7.14",
"vue-loader": "17.2.2",
"vue-router": "3.6.5",
"vue-template-compiler": "2.7.14",
"vue-tsc": "1.8.8"
},
Expand Down
Loading
Loading