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

[Layout] Add story with gutter #40

Merged
merged 2 commits into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 9 additions & 0 deletions src/qComponents/QCol/QCol.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Component from './src/QCol';

describe('QCol', () => {
it('should match snapshot', async () => {
const { element } = shallowMount(Component);

expect(element).toMatchSnapshot();
});
});
7 changes: 7 additions & 0 deletions src/qComponents/QCol/__snapshots__/QCol.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`QCol should match snapshot 1`] = `
<div
class="q-col"
/>
`;
9 changes: 9 additions & 0 deletions src/qComponents/QRow/QRow.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Component from './src/QRow';

describe('QRow', () => {
it('should match snapshot', async () => {
const { element } = shallowMount(Component);

expect(element).toMatchSnapshot();
});
});
7 changes: 7 additions & 0 deletions src/qComponents/QRow/__snapshots__/QRow.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`QRow should match snapshot 1`] = `
<div
class="q-row"
/>
`;
116 changes: 116 additions & 0 deletions stories/components/Layout/Layout.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import QCol from '../../../src/qComponents/QCol';
import QRow from '../../../src/qComponents/QRow';
import './layout.scss';

export default {
title: 'Components/Layout',
subcomponents: { QRow, QCol },
argTypes: {
gutter: {
name: 'gutter',
control: 'text',
type: { name: 'string', required: false },
description: 'grid spacing (in CSS units)',
table: {
type: {
summary: ['string']
}
}
}
}
};

export const QRowStory = (_, { argTypes }) => ({
props: Object.keys(argTypes),
computed: {
demoStyles() {
return {
'--layout-gutter': (this.gutter ?? '').trim()
};
}
},
template: `
<div class="demo" :style="demoStyles">
<q-row class="demo__row">
<q-col class="demo__col" cols="8">
<div class="demo__content">8</div>
</q-col>

<q-col class="demo__col" cols="4">
<div class="demo__content">4</div>
</q-col>

<q-col class="demo__col" cols="4">
<div class="demo__content">4</div>
</q-col>

<q-col class="demo__col" cols="4">
<div class="demo__content">4</div>
</q-col>

<q-col class="demo__col" cols="2">
<div class="demo__content">2</div>
</q-col>

<q-col class="demo__col" cols="2">
<div class="demo__content">2</div>
</q-col>
</q-row>

<q-row class="demo__row">
<q-col class="demo__col" cols="2">
<div class="demo__content">2</div>
</q-col>

<q-col class="demo__col" cols="8">
<div class="demo__content">8</div>
</q-col>

<q-col class="demo__col" cols="2">
<div class="demo__content">2</div>
</q-col>
</q-row>

<q-row class="demo__row">
<q-col class="demo__col" cols="2">
<div class="demo__content">2</div>
</q-col>

<q-col class="demo__col" cols="5">
<div class="demo__content">5</div>
</q-col>

<q-col class="demo__col" cols="2">
<div class="demo__content">2</div>
</q-col>

<q-col class="demo__col" cols="3">
<div class="demo__content">3</div>
</q-col>
</q-row>

<q-row class="demo__row">
<q-col class="demo__col" cols="5">
<div class="demo__content">5</div>
</q-col>

<q-col class="demo__col" cols="7">
<div class="demo__content">7</div>
</q-col>
</q-row>

<q-row class="demo__row"
>
ViZhe marked this conversation as resolved.
Show resolved Hide resolved
<q-col class="demo__col" cols="10">
<div class="demo__content">10</div>
</q-col>

<q-col class="demo__col" cols="2">
<div class="demo__content">2</div>
</q-col>
</q-row>
</div>
`
});

QRowStory.storyName = 'Default';
31 changes: 15 additions & 16 deletions stories/components/Layout/QCol.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,21 @@ export default {
export const QColStory = (_, { argTypes }) => ({
props: Object.keys(argTypes),
template: `
<q-row
class="demo-row"
>
<q-col
cols="2"
class="demo-col"
>2</q-col>
<q-col
v-bind="$props"
class="demo-col"
>dyn</q-col>
<q-col
cols="2"
class="demo-col"
>2</q-col>
</q-row>
<div class="demo">
<q-row class="demo__row">
<q-col class="demo__col" cols="2">
<div class="demo__content">2</div>
</q-col>

<q-col class="demo__col" v-bind="$props">
<div class="demo__content">dyn</div>
</q-col>

<q-col class="demo__col" cols="2">
<div class="demo__content">2</div>
</q-col>
</q-row>
</div>
`
});

Expand Down
36 changes: 17 additions & 19 deletions stories/components/Layout/QRow.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ export default {
alignV: {
control: {
type: 'select',
options: ['start', 'end', 'center', 'baseline', 'stretch']
options: [null, 'start', 'end', 'center', 'baseline', 'stretch']
}
},
alignH: {
control: {
type: 'select',
options: ['start', 'end', 'center', 'between', 'around']
options: [null, 'start', 'end', 'center', 'between', 'around']
}
}
}
Expand All @@ -25,23 +25,21 @@ export default {
export const QRowStory = (_, { argTypes }) => ({
props: Object.keys(argTypes),
template: `
<q-row
v-bind="$props"
class="demo-row"
>
<q-col
cols="2"
class="demo-col"
>2</q-col>
<q-col
cols="4"
class="demo-col"
>4</q-col>
<q-col
cols="2"
class="demo-col"
>2</q-col>
</q-row>
<div class="demo">
<q-row class="demo__row" v-bind="$props">
<q-col class="demo-col" cols="2">
<div class="demo__content">2</div>
</q-col>

<q-col class="demo__col" cols="4">
<div class="demo__content" style="height: 25px;">4</div>
</q-col>

<q-col class="demo__col" cols="2">
<div class="demo__content">2</div>
</q-col>
</q-row>
</div>
`
});

Expand Down
34 changes: 24 additions & 10 deletions stories/components/Layout/layout.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
.demo-row {
width: 500px;
min-height: 50px;
background-color: var(--color-tertiary-gray);
}
.demo {
display: flex;
flex-direction: column;
align-items: center;
width: 1000px;
max-width: 100%;

&__row {
width: 100%;

.demo-col {
background-color: var(--color-tertiary-gray-ultra-darker);
border-radius: var(--border-radius-base);
&:nth-child(odd) {
.demo__content {
background-color: var(--color-primary-blue-light);
}
}
}

&:nth-child(odd) {
background-color: var(--color-tertiary-gray-ultra-dark);
&__content {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 50px;
margin-bottom: var(--layout-gutter);
background-color: var(--color-primary-blue-aqua);
border-radius: var(--border-radius-base);
}
}