Skip to content

Commit

Permalink
Merge branch 'feature/update-paragraph' into feature/update
Browse files Browse the repository at this point in the history
  • Loading branch information
ofrankowska committed Jul 3, 2020
2 parents 2d59978 + 3c0e2f7 commit 9085ad2
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 17 deletions.
34 changes: 17 additions & 17 deletions _src /atoms/paragraph/Paragraph.scss
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
@import '../../../assets/styles/_globals.scss';
// @import '../../../assets/styles/_globals.scss';

$paragraph__margin : 0 0 $spacer--medium 0 !default;
$paragraph__color : $color-secondary !default;
$paragraph__font-family: $font-family-base !default;
$paragraph__font-weight: $font-weight-normal !default;
$paragraph__line-height: $font-line-height !default;
$paragraph__font-size : $font-size-base !default;
$paragraph__transition : none !default;
// $paragraph__margin : 0 0 $spacer--medium 0 !default;
// $paragraph__color : $color-secondary !default;
// $paragraph__font-family: $font-family-base !default;
// $paragraph__font-weight: $font-weight-normal !default;
// $paragraph__line-height: $font-line-height !default;
// $paragraph__font-size : $font-size-base !default;
// $paragraph__transition : none !default;

.a-paragraph {
margin: $paragraph__margin;
color: $paragraph__color;
font-weight: $paragraph__font-weight;
font-size: $paragraph__font-size;
font-family: $paragraph__font-family;
line-height: $paragraph__line-height;
transition: $paragraph__transition;
}
// .a-paragraph {
// margin: $paragraph__margin;
// color: $paragraph__color;
// font-weight: $paragraph__font-weight;
// font-size: $paragraph__font-size;
// font-family: $paragraph__font-family;
// line-height: $paragraph__line-height;
// transition: $paragraph__transition;
// }
4 changes: 4 additions & 0 deletions src/atoms/paragraph/Paragraph.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.a-paragraph {
@apply mb-4;
@apply text-primary leading-relaxed;
}
7 changes: 7 additions & 0 deletions src/atoms/paragraph/Paragraph.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<component
:is="tag"
class="a-paragraph"
>
<!-- @slot Slot for paragraph content -->
<slot />
</component>
12 changes: 12 additions & 0 deletions src/atoms/paragraph/Paragraph.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// @vue/component
export default {
props: {
/**
* To use another tag instead of `p`
*/
tag: {
type: String,
default: 'p'
}
}
}
36 changes: 36 additions & 0 deletions src/atoms/paragraph/Paragraph.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { mount } from '@vue/test-utils'
import AParagraph from './Paragraph.vue'

describe('Paragraph', () => {
it('has default structure', () => {
const wrapper = mount(AParagraph)

expect(wrapper.is('p')).toBe(true)
expect(wrapper.classes()).toContain('a-paragraph')
expect(wrapper.classes().length).toBe(1)
})

it('renders custom root element', () => {
const wrapper = mount(AParagraph, {
propsData: {
tag: 'span'
}
})

expect(wrapper.is('span')).toBe(true)
expect(wrapper.classes()).toContain('a-paragraph')
expect(wrapper.classes().length).toBe(1)
})

it('renders slot text when passed', () => {
const wrapper = mount(AParagraph, {
slots: {
default: `
<span>Alpaca UI</span>
`
}
})
expect(wrapper.find('p span').exists()).toBe(true)
expect(wrapper.find('p span').text()).toEqual('Alpaca UI')
})
})
41 changes: 41 additions & 0 deletions src/atoms/paragraph/Paragraph.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { text } from '@storybook/addon-knobs'

import AParagraph from './Paragraph.vue'

const sampleParagraphText = 'Velit proident fugiat pariatur irure sint non ut non. Adipisicing aliqua consectetur nisi aliquip velit. Nisi pariatur est consectetur culpa occaecat enim nulla laborum ex. Consectetur incididunt minim cupidatat ad aliquip. Ea non ipsum ut consequat sit adipisicing eiusmod do. Officia incididunt cillum incididunt aliquip sit labore laboris do cillum commodo occaecat voluptate ea aliqua.'

export default {
title: 'Atoms/Paragraph',
component: AParagraph
}

export const Default = () => ({
components: { AParagraph },
props: {
textKnob: {
default: text('Paragraph text', sampleParagraphText)
}
},
template: `
<a-paragraph>
{{ textKnob }}
</a-paragraph>
`
})

export const CustomTag = () => ({
components: { AParagraph },
props: {
textKnob: {
default: text('Paragraph text', sampleParagraphText)
},
tagKnob: {
default: text('Html tag', 'div')
}
},
template: `
<a-paragraph :tag="tagKnob">
{{ textKnob }}
</a-paragraph>
`
})
13 changes: 13 additions & 0 deletions src/atoms/paragraph/Paragraph.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<template src="./Paragraph.html" />

<script>
import AParagraph from './Paragraph.js'
export default {
name: 'AlpacaParagraph',
mixins: [AParagraph]
}
</script>

<style lang="css" src="./Paragraph.css" />

0 comments on commit 9085ad2

Please sign in to comment.