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

Share popup modal separation #1107

Draft
wants to merge 68 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 62 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
b193b42
Journal article main content updates (#1101)
discodavey Jan 10, 2022
4a282e0
Initial work for creating share modal popup
discodavey Jan 14, 2022
3e35473
Add table variations and fix bug for lists inside tables (#1104)
discodavey Jan 24, 2022
ced7d4d
Table list indentation issue (#1105)
discodavey Jan 25, 2022
0acea23
Changes to js and adding data behaviour
discodavey Jan 25, 2022
6ab193f
Fix css for modal
discodavey Jan 25, 2022
a9eb22b
removing console logs on modal
discodavey Jan 25, 2022
8839aa0
Merge branch 'develop' into share-popup-modal
discodavey Jan 25, 2022
b60b0fd
Move modal-window to atoms
nlisgo Jan 25, 2022
1e4a664
Adding modal json file for parameters
discodavey Jan 25, 2022
0aca963
Add yaml parameters for modal window
discodavey Jan 26, 2022
a16bbbb
Add variations for modal window
discodavey Jan 27, 2022
63a0c12
Add share modal content and styling
discodavey Jan 31, 2022
4a60f40
Add Citations json and template changes
discodavey Feb 2, 2022
667a147
Styling citations
discodavey Feb 2, 2022
dd3b44b
Add without link to doi atom
discodavey Feb 2, 2022
46d2179
Introduce doi variant without a link
nlisgo Feb 2, 2022
cde76eb
Cleanup of duplication in doi and reference templates
nlisgo Feb 2, 2022
e244a97
no-wtf
nlisgo Feb 2, 2022
9bd47e3
Move all modals to atoms and refactor css
discodavey Feb 3, 2022
813f6d8
Refactor content for json file modal window
discodavey Feb 3, 2022
30d43a3
Adding Clipboard JS for modal window share and citations
discodavey Feb 3, 2022
7811f62
Add button success
discodavey Feb 3, 2022
72a2974
Button styling on modal windows
discodavey Feb 4, 2022
3f3c044
Remove border
discodavey Feb 8, 2022
686b3ac
Refactor code and some fixes
discodavey Feb 10, 2022
c716c0a
Adding socials to this PR from old PR
discodavey Feb 10, 2022
e21ab97
Remove Close text for modal share
discodavey Feb 10, 2022
f375e88
Refactor styling on modal
discodavey Feb 11, 2022
7ecfb1d
Refactor modal window css and template
discodavey Feb 14, 2022
123ff6a
Refactor Modal Windows
discodavey Feb 17, 2022
baf406b
Refactor json files for Modal Window
discodavey Feb 17, 2022
7793ab3
Merge branch 'develop' into share-popup-modal-separation
discodavey Feb 21, 2022
e7b4a52
Add button collection to modal citations
discodavey Feb 22, 2022
34e1cf5
Refactor colours to variables on button--secondary
discodavey Feb 22, 2022
4aebeb0
Remove redundant properties
nlisgo Feb 22, 2022
a30d6d1
Add new button-collection variant
nlisgo Feb 22, 2022
14b04d8
Merge branch 'share-popup-modal-separation' of github.com:elifescienc…
nlisgo Feb 22, 2022
bdfcae4
refactor hover state for button--secondary
discodavey Feb 22, 2022
b3012d1
Add button secondary variant
nlisgo Feb 22, 2022
28604a7
Adjust classes
nlisgo Feb 22, 2022
d0b6eca
Remove some styles
nlisgo Feb 22, 2022
6fdf7da
Add condition
nlisgo Feb 22, 2022
6eaebdb
Clean data
nlisgo Feb 22, 2022
38a7311
Merge branch 'share-popup-modal-separation' of github.com:elifescienc…
nlisgo Feb 22, 2022
2ddbc17
Add styling for refactored buttons for citations modal window
discodavey Feb 22, 2022
e03fb9e
Introduce button clipboard and button collection to modal
nlisgo Feb 22, 2022
f2c5f7a
Merge branch 'share-popup-modal-separation' of github.com:elifescienc…
nlisgo Feb 22, 2022
5d2212c
Allow a trigger id to be set for the modal
nlisgo Feb 22, 2022
fbbffbd
adding email icon for share modal window
discodavey Feb 23, 2022
69b22eb
refactor url paths for social media icons
discodavey Feb 23, 2022
deb7c5f
Merge branch 'develop' into share-popup-modal-separation
discodavey Feb 23, 2022
1b9e25f
Introduce placeholder for test for button clipboard
nlisgo Feb 23, 2022
0476e36
skip placeholder test
nlisgo Feb 23, 2022
ca88a76
Refactor social media sharers for modal share
discodavey Feb 23, 2022
f150381
Update json files for social media sharers with LinkedIn url
discodavey Feb 23, 2022
90b61ff
Allow button clipboard copy function to be overwritten for tests
nlisgo Feb 23, 2022
1afb84a
Merge branch 'share-popup-modal-separation' of github.com:elifescienc…
nlisgo Feb 23, 2022
d012c92
Refactoring modal citation and share styling and adapting for journal…
discodavey Feb 23, 2022
590f017
Mock copyToClipboard method
nlisgo Feb 23, 2022
830db93
Add linkedInUrl to socialMediaSharers
nlisgo Feb 23, 2022
a7d7725
match schema
nlisgo Feb 23, 2022
4e5c79f
Removing as not anything to do with the project
discodavey Feb 24, 2022
223aedb
Merge branch 'share-popup-modal-separation' of https://github.com/eli…
discodavey Feb 24, 2022
ad77a7f
Refactor css for modal window
discodavey Feb 24, 2022
815ecb4
Reverted back to previous
discodavey Feb 24, 2022
b56e787
Merge branch 'develop' of github.com:elifesciences/pattern-library in…
nlisgo Feb 25, 2022
c85d97f
remove file and redundant sass
nlisgo Feb 25, 2022
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
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
nlisgo marked this conversation as resolved.
Show resolved Hide resolved
14 changes: 14 additions & 0 deletions assets/img/icons/email-default.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions assets/img/icons/tick-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions assets/js/components/ButtonClipboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

module.exports = class Modal {
constructor($elm) {
if (!$elm) {
return;
}

this.$elm = $elm;

this.$elm.addEventListener('click', () => {
this.copyToClipboard(this.$elm.getAttribute('data-clipboard'), () => {
this.$elm.classList.add('button--success', 'button--fixed-width');
this.$elm.textContent = 'Copied!';
});
});
}

copyToClipboard(text, onSuccess) {
navigator.clipboard.writeText(text).then(onSuccess);
}
};
50 changes: 50 additions & 0 deletions assets/js/components/Modal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
'use strict';

module.exports = class Modal {

constructor($elm, _window = window, doc = document) {
if (!$elm) {
return;
}

this.$elm = $elm;
this.window = _window;
this.doc = doc;

const $triggerId = this.$elm.getAttribute('data-trigger-id');
let $trigger;

if (!$triggerId || !this.doc.getElementById($triggerId)) {
$trigger = this.$elm.querySelector('.modal-click');
} else {
$trigger = this.doc.getElementById($triggerId);
}

this.modalWindow = this.$elm.querySelector('.modal-container');
$trigger.addEventListener('click', (event) => this.modalToggle(event));
this.$elm.querySelector('.modal-content__button').addEventListener('click', (event) => this.modalToggle(event));
this.window.addEventListener('click', (event) => this.windowOnClick(event));

this.window.addEventListener('resize', () => {
this.modalWindow.classList.remove('modal-content__show');
});

this.modalSetup();
}

modalToggle(event) {
this.modalWindow.classList.toggle('modal-content__show');
event.preventDefault();
}

windowOnClick(event) {
if (event.target === this.modalWindow) {
this.modalToggle(event);
}
}

modalSetup() {
this.$elm.classList.remove('modal-nojs');
}

};
2 changes: 2 additions & 0 deletions assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Components.ArticleSection = require('./components/ArticleSection');
Components.AssetNavigation = require('./components/AssetNavigation');
Components.AssetViewer = require('./components/AssetViewer');
Components.AudioPlayer = require('./components/AudioPlayer');
Components.ButtonClipboard = require('./components/ButtonClipboard');
Components.CallToAction = require('./components/CallToAction');
Components.CarouselItem = require('./components/CarouselItem');
Components.Carousel = require('./components/Carousel');
Expand All @@ -31,6 +32,7 @@ Components.MainMenu = require('./components/MainMenu');
Components.Math = require('./components/Math');
Components.MediaChapterListingItem = require('./components/MediaChapterListingItem');
Components.Metrics = require('./components/Metrics');
Components.Modal = require('./components/Modal');
Components.Pager = require('./components/Pager');
Components.PersonalisedCoverDownload = require('./components/PersonalisedCoverDownload');
Components.Popup = require('./components/Popup');
Expand Down
1 change: 1 addition & 0 deletions assets/sass/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ $color-text-secondary-dark: #6e6e6e;
$color-text-placeholder: #bdbdbd;
$color-text-dividers: #e0e0e0;
$color-text-ui-background: #fff;
$color-text-ui-background-secondary: #f7f7f7;
$color-text-ui-background-hue: #f5f5f5;
$color-text-ui-code: #f7f7f7;

Expand Down
23 changes: 23 additions & 0 deletions assets/sass/patterns/atoms/buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
text-transform: uppercase;
}

.button--fixed-width {
nlisgo marked this conversation as resolved.
Show resolved Hide resolved
min-width: 189px;
}

.button--default {
@include colors($color-primary);
@include padding(15 36 14);
Expand All @@ -35,6 +39,15 @@
}
}

.button--secondary {
@include colors($color-text-ui-background-secondary, $color-text-dividers, $color-text);
@include padding(15 36 14);

&:hover {
@include colors($color-text-dividers, $color-text-dividers, $color-text);
}
}

.button--outline {
@include colors($color-text--reverse, $color-primary, $color-primary);
@include padding(15 36 14);
Expand Down Expand Up @@ -97,3 +110,13 @@

cursor: not-allowed;
}

.button--success {
background: $color-success;
border: 1px solid $color-success;

&:hover {
background-color: #2b7306;
nlisgo marked this conversation as resolved.
Show resolved Hide resolved
border: 1px solid #2b7306;
}
}
138 changes: 138 additions & 0 deletions assets/sass/patterns/atoms/modal-window.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
.modal-container {
background-color: rgba(255,255,255,0.5);
height: 100%;
left: 0;
position: fixed;
top: 0;
width: 100%;
visibility: hidden;
}

.modal-content {
background-color: #fff;
border-radius: 3px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.22);
display: grid;
margin: 0;
padding: 36px;

@media only all and (min-width: #{get-rem-from-px($bkpt-site--small)}em) {
margin: 24px;
}

@media only all and (min-width: #{get-rem-from-px($bkpt-site--medium + 48)}em) {
margin: 24px auto;
max-width: 730px;
}

h6 {
@include font-size-and-vertical-height($font-size-h6-in-px);
grid-column: 1/3;
grid-row: 1;
justify-self: start;
padding-top: 0;
}

.social-media-sharers {
@media only all and (max-width: #{get-rem-from-px($bkpt-site--small - 1)}em) {
@include padding(24, "top");
display: flex;
grid-column: 1/3;
grid-row: 4;
justify-content: center;
}
}

.reference {
font-family: $font-secondary;
grid-column: 1/3;

.doi {
@include margin(12, "top");
@include margin(36, "bottom");
display: flex;
}
}

.button-collection {
display: unset;
flex-direction: column;
grid-column: 1/3;

.button-collection__item {
float: none;
}

.button {
@include margin(12, "bottom");
width: 100%;
}

@media only all and (min-width: #{get-rem-from-px($bkpt-site--medium)}em) {
grid-column: 1/3;

.button-collection__item {
float: left;
}

.button {
@include margin(12, "bottom");
line-height: 1.5;
padding: 15px 24px 14px;
text-decoration: none;
width: auto;
}
}
}
}

.modal-content__body {
display: grid;
grid-column: 1/3;

.button {
justify-self: center;
margin-bottom: 24px;
Copy link
Member

Choose a reason for hiding this comment

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

There are a few cases where it would be appropriate to use a mixin such as here @include margin(24, "bottom");

Copy link
Member Author

Choose a reason for hiding this comment

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

Had not finished this part of the changes

}
}

.modal-content__show {
opacity: 1;
visibility: visible;
}

.modal-content__close-button {
@include padding(0 25 0 0);
background: url(../img/icons/close.svg) right 4px no-repeat;
color: $color-text;
font-family: $font-secondary;
font-weight: bold;
grid-column: 2/3;
grid-row: 1;
justify-self: end;
}

.modal-nojs {
visibility: hidden;
}

.modal-content__clipboard {
@include margin(24, "bottom");
@include padding(12);
border: 1px solid $color-text-dividers;
font-family: $font-secondary;
grid-column: 1/3;
grid-row: 2;
justify-self: initial;
word-break: break-word;

&.reference {
@include margin(0, "bottom");
border: none;
padding: 0;
}
}

.social-media-sharers {
display: flex;
}
1 change: 0 additions & 1 deletion assets/sass/patterns/atoms/reference.scss
Original file line number Diff line number Diff line change
Expand Up @@ -187,5 +187,4 @@ a.reference__authors_link:hover {
}

}

nlisgo marked this conversation as resolved.
Show resolved Hide resolved
}
41 changes: 39 additions & 2 deletions assets/sass/patterns/atoms/social-media-sharers.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,20 @@
// Fill: solid

.social-media-sharers {
flex-grow: 0;
flex-basis: 24px;
@include margin(0);
@include padding(0);
display: flex;
justify-content: center;
margin-bottom: 24px;

li {
list-style: none;
margin-right: 6px;

&:last-child {
margin-right: 0;
}
}
}

.social-media-sharer,
Expand Down Expand Up @@ -65,3 +77,28 @@
fill: #fff;
stroke: none;
}

.email {
background: url("../img/icons/email-default.svg") no-repeat 0 0;
text-indent: -5000px;
}

.facebook {
background: url("../img/icons/facebook.svg") no-repeat 0 0;
text-indent: -5000px;
}

.twitter {
background: url("../img/icons/twitter.svg") no-repeat 0 0;
text-indent: -5000px;
}

.linkedin {
background: url("../img/icons/linkedin.svg") no-repeat 0 0;
text-indent: -5000px;
}

.reddit {
background: url("../img/icons/reddit.svg") no-repeat 0 0;
text-indent: -5000px;
}
Loading