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

Feature/53585 Migrate cookie message #187

Open
wants to merge 30 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
f768d2a
#53585 - Move component to the molecules
May 20, 2019
e72ddc6
#53585 - Add 'a' prefix in class
May 20, 2019
99e9126
#53585 - Add 'a' prefix in class
May 20, 2019
936d231
#53585 - Add slots
May 20, 2019
088e701
#53585 - Add description for slots and props
May 20, 2019
9c29255
#53585 - Add test for cookie message
May 20, 2019
8931516
#53585 - Change text color to increase contrast for a11y
May 20, 2019
eef1c1d
#53585 - Use color variable
May 20, 2019
a89787d
Merge branch 'develop' into feature/53585
Aekal May 21, 2019
05cb64e
Merge branch 'develop' into feature/53585
Aekal May 21, 2019
38314bb
#53585 - Move arialabels to story
May 21, 2019
5aef2df
#53585 - Remove closeIcon props
May 21, 2019
e7106f9
#53585 - Move dataType to data
May 21, 2019
011dae8
#53585 - Add knobs for custom button
May 21, 2019
3dd67c7
#53585 - Add knobs for default button
May 21, 2019
a3873df
#53585 - Remove unnecessary brackets
May 21, 2019
c0acf88
#53585 - Add knobs,default value for storageName
May 22, 2019
a95531c
#53585 - Fix styles
May 22, 2019
ad12cfb
Merge branch 'develop' into feature/53585
May 28, 2019
b2a0f6a
#53585 - Revert style changes
May 28, 2019
219c752
#53585 - Move transitions
May 28, 2019
0b70126
Merge branch 'develop' into feature/53585
May 30, 2019
8a4c4a8
Merge branch 'develop' into feature/53585
May 31, 2019
d0e26d3
#53585 - Fix line-height
May 31, 2019
af79012
#53585 - Remove connect with localStorage
Jun 4, 2019
a86980e
#53585 - Change this.$root.$el on this.$el
Jun 4, 2019
8faab0b
#53585 - Fix styles
Jun 4, 2019
3dc1b08
Merge branch 'develop' into feature/53585
Jun 4, 2019
a995b3b
#53585 - Remove unnecessary test, after changes in component
Jun 4, 2019
a763b31
Merge remote-tracking branch 'origin/feature/53585' into feature/53585
Jun 4, 2019
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
24 changes: 0 additions & 24 deletions components/src/02-elements/cookie-message/CookieMessage.html

This file was deleted.

17 changes: 0 additions & 17 deletions components/src/02-elements/cookie-message/CookieMessage.stories.js

This file was deleted.

2 changes: 1 addition & 1 deletion components/src/03-modules/footer/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ALink from '../../atoms/link/Link.vue'
import AButton from '../../atoms/button/Button.vue'
import AList from '../../atoms/list/List.vue'
import AListItem from '../../atoms/list-item/ListItem.vue'
import ACookieMessage from '../../02-elements/cookie-message/CookieMessage.vue'
import ACookieMessage from '../../molecules/cookie-message/CookieMessage.vue'
import ADropdownList from '../../02-elements/dropdown-list/DropdownList.vue'
import ADropdownListItem from '../../02-elements/dropdown-list-item/DropdownListItem.vue'
import ANewsletter from '../../03-modules/newsletter/Newsletter.vue'
Expand Down
30 changes: 30 additions & 0 deletions components/src/molecules/cookie-message/CookieMessage.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<div
:class="['a-cookie-message', isOpen && 'a-cookie-message--open']"
:data-type="dataType"
:aria-label="ariaLabel"
tabindex="0"
>
<div class="a-cookie-message__container">
<div class="a-cookie-message__text">
<!-- @slot Content slot -->
<slot />
</div>
<!-- @slot Close button (Scoped slot) -->
<slot
name="button"
:close-bar="closeBar"
>
<a-button
:aria-label="closeAriaLabel"
class="a-cookie-message__close"
@click.native="closeBar()"
Aekal marked this conversation as resolved.
Show resolved Hide resolved
>
{{ closeButton }}
<a-icon
:icon="closeIcon"
Aekal marked this conversation as resolved.
Show resolved Hide resolved
class="a-cookie-message__close-icon"
/>
</a-button>
</slot>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,37 @@ export default {
AButton
},
props: {
text: {
type: String,
required: true
},
/**
* Data typeQuantity value (used with v-model)
*/
dataType: {
Aekal marked this conversation as resolved.
Show resolved Hide resolved
type: String,
required: true
default: null
},
/**
* Icon for close button
*/
closeIcon: {
type: String,
default: null
},
/**
* Text for close button
*/
closeButton: {
type: String,
default: null
},
/**
* Aria label for container
*/
ariaLabel: {
type: String,
default: 'Cookie policy message'
Aekal marked this conversation as resolved.
Show resolved Hide resolved
},
/**
* Aria label for close button
*/
closeAriaLabel: {
type: String,
default: 'Close cookie message'
Aekal marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $cookie-message__width : 100% !default;
$cookie-message__background-color : $gray-lightest !default;
$cookie-message__font-size : $font-size-small !default;
$cookie-message__font-family : $font-family-base !default;
$cookie-message__text-color : $gray !default;
$cookie-message__text-color : $gray-dark !default;
$cookie-message__text-padding : $spacer--medium $spacer--medium 0 $spacer--medium !default;
$cookie-message__text-padding--small : $spacer--medium $spacer $spacer--medium $spacer--medium !default;
$cookie-message__link-color : $blue !default;
Expand All @@ -19,7 +19,7 @@ $cookie-message__close-icon-margin-left: $spacer !default;
$cookie-message__close-icon-transition : $transition-base !default;


.cookie-message {
.a-cookie-message {
display: none;
align-items: stretch;
box-sizing: border-box;
Expand Down Expand Up @@ -57,10 +57,6 @@ $cookie-message__close-icon-transition : $transition-base !default;
}
}

&__link {
color: $cookie-message__link-color;
}

&__close {
display: flex;
flex-basis: auto;
Expand Down Expand Up @@ -106,6 +102,6 @@ $cookie-message__close-icon-transition : $transition-base !default;
}
}

.cookie-message__text > a {
@extend .cookie-message__link;
.a-cookie-message__text > a {
color: $cookie-message__link-color;
}
32 changes: 32 additions & 0 deletions components/src/molecules/cookie-message/CookieMessage.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { mount } from '@vue/test-utils'
import ACookieMessage from './CookieMessage.vue'

describe('Cookie message', () => {
it('has default structure', () => {
const wrapper = mount(ACookieMessage)
expect(wrapper.is('div')).toBe(true)
expect(wrapper.classes()).toContain('a-cookie-message')
})

it('renders slots content when passed', () => {
const wrapper = mount(ACookieMessage, {
slots: {
default: `<span>Sample content</span>`,
button: `<button>Sample button</button>`
}
})

const span = wrapper.find('.a-cookie-message span')
expect(span.exists()).toBe(true)
expect(span.text()).toEqual('Sample content')
expect(wrapper.find('button').text()).toBe('Sample button')
})

it('close cookie message info', () => {
const wrapper = mount(ACookieMessage)
const closeBtn = wrapper.find('.a-cookie-message__close')
expect(wrapper.classes().length).toBe(2)
closeBtn.trigger('click')
expect(wrapper.classes().length).toBe(1)
})
})
40 changes: 40 additions & 0 deletions components/src/molecules/cookie-message/CookieMessage.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { storiesOf } from '@storybook/vue'

import ALink from '../../atoms/link/Link.vue'
import ACookieMessage from './CookieMessage.vue'

storiesOf('Molecules/CookieMessage', module)
.addParameters({ info: true })
.add('Default', () => ({
components: { ACookieMessage, ALink },
template: `
<a-cookie-message
closeIcon="close"
dataType="cookie"
Aekal marked this conversation as resolved.
Show resolved Hide resolved
closeButton="Close"
Aekal marked this conversation as resolved.
Show resolved Hide resolved
>
<a-link href='#'>
Example link
</a-link>
Find out more about their purpose and settings in your browser. By browsing the site you are agreeing to use cookies according to your browser settings."
</a-cookie-message>
`
}))
.add('With slots', () => ({
components: { ACookieMessage, ALink },
template: `
<a-cookie-message
closeIcon="close"
dataType="cookie"
Aekal marked this conversation as resolved.
Show resolved Hide resolved
closeButton="Close"
>
<a-link href='#'>
Example link
</a-link>
Find out more about their purpose and settings in your browser. By browsing the site you are agreeing to use cookies according to your browser settings."
Aekal marked this conversation as resolved.
Show resolved Hide resolved
<template #button="{ closeBar }">
<button @click="closeBar">Custom button</button>
</template>
</a-cookie-message>
`
}))