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 2 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
2 changes: 1 addition & 1 deletion components/src/molecules/cookie-message/CookieMessage.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div
:class="['a-cookie-message', isOpen && 'a-cookie-message--open']"
:data-type="dataType"
:data-type="storageName"
:aria-label="ariaLabel"
tabindex="0"
>
Expand Down
14 changes: 10 additions & 4 deletions components/src/molecules/cookie-message/CookieMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ export default {
AButton
},
props: {
/**
* Storage name
*/
storageName: {
type: String,
default: 'cookie'
},
/**
* Text for close button
*/
Expand All @@ -32,12 +39,11 @@ export default {
},
data: () => {
return {
isOpen: false,
dataType: 'cookie'
isOpen: false
}
},
mounted () {
if (localStorage.getItem(this.dataType) !== 'closed') {
if (localStorage.getItem(this.storageName) !== 'closed') {
this.isOpen = true
}
},
Expand All @@ -47,7 +53,7 @@ export default {

const focusable = this.$root.$el.querySelectorAll('button:not([disabled]), a[href], area[href] input:not([disabled]), select:not([disabled]), textarea:not([disabled]), *[tabindex]:not([tabindex="-1"]), object, embed, *[contenteditable]')
szafran89 marked this conversation as resolved.
Show resolved Hide resolved

localStorage.setItem(this.dataType, 'closed')
localStorage.setItem(this.storageName, 'closed')
szafran89 marked this conversation as resolved.
Show resolved Hide resolved
// after closing message box move focus on first focusable element on the page
if (focusable.length) {
let firstFocusable = [...focusable].find(el => el.offsetParent !== null)
Expand Down
40 changes: 23 additions & 17 deletions components/src/molecules/cookie-message/CookieMessage.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ $cookie-message__close-icon-transition : $transition-base !default;
font-family: $cookie-message__font-family;
background-color: $cookie-message__background-color;

&--open {
display: flex;
}

szafran89 marked this conversation as resolved.
Show resolved Hide resolved
&__container {
display: flex;
flex-wrap: wrap;
Expand Down Expand Up @@ -74,34 +78,36 @@ $cookie-message__close-icon-transition : $transition-base !default;
cursor: pointer;

&:active,
&:hover {
&:hover,
&:focus {
color: $cookie-message__close-color;
background: none;

.a-cookie-message__close-icon {
transition: $cookie-message__close-icon-transition;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this transition to &__close-icon styles, now the transition effect works only in one-way

fill: $color-primary;
szafran89 marked this conversation as resolved.
Show resolved Hide resolved
}
}

@include mq($screen-s) {
padding: $cookie-message__close-padding--small;
}
}

&__close-icon {
width: $cookie-message__close-icon-size;
height: $cookie-message__close-icon-size;
margin-left: $cookie-message__close-icon-margin-left;
fill: $cookie-message__close-color;
&-icon {
szafran89 marked this conversation as resolved.
Show resolved Hide resolved
width: $cookie-message__close-icon-size;
height: $cookie-message__close-icon-size;
margin-left: $cookie-message__close-icon-margin-left;
fill: $cookie-message__close-color;

&:hover,
&:focus {
transition: $cookie-message__close-icon-transition;
fill: $color-primary;
&:hover,
&:focus {
transition: $cookie-message__close-icon-transition;
szafran89 marked this conversation as resolved.
Show resolved Hide resolved
fill: $color-primary;
}
}
}

&--open {
display: flex;
&__text > a {
color: $cookie-message__link-color;
szafran89 marked this conversation as resolved.
Show resolved Hide resolved
}
}

.a-cookie-message__text > a {
color: $cookie-message__link-color;
}
28 changes: 19 additions & 9 deletions components/src/molecules/cookie-message/CookieMessage.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,50 @@ storiesOf('Molecules/CookieMessage', module)
components: { ACookieMessage, ALink },
props: {
textKnobs: {
default: text('Text', 'Close')
default: text('Button text', 'Button text')
},
linkText: {
default: text('Link text', 'Example link')
},
infoText: {
default: text('Info text', '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.')
}
},
template: `
<a-cookie-message
dataType="cookie"
:closeButton="textKnobs"
:close-button="textKnobs"
aria-label="Cookie policy message"
close-aria-label="Close cookie message"
>
<a-link href='#'>
Example link
{{ linkText }}
</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."
{{ infoText }}
</a-cookie-message>
`
}))
.add('With slots', () => ({
components: { ACookieMessage, ALink },
props: {
textKnobs: {
default: text('Text', 'Custom button')
default: text('Button text', 'Button text')
},
linkText: {
default: text('Link text', 'Link text')
},
infoText: {
default: text('Info text', 'Info text')
}
},
template: `
<a-cookie-message
dataType="cookie"
aria-label="Cookie policy message"
close-aria-label="Close cookie message"
>
<a-link href='#'>
Example link
{{ linkText }}
</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."
{{ infoText }}
<template #button="{ closeBar }">
<button @click="closeBar">
{{ textKnobs }}
Expand Down