-
Notifications
You must be signed in to change notification settings - Fork 3
[TWE-661] Add sticky call to action and new link type for all call to actions #402
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
Merged
Merged
Changes from 13 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
f1de4fd
Add pipedrive_link type to CTAs and support for the modal it uses.
095519e
Lint changes
ce6eeec
[WIP] Sticky CTA block, currently fixing styling
90f443e
[WIP] Still playing with styling
0c2cfb3
add yaml for pattern library
3db8c41
[WIP] continuing
50b064f
Refactor to generalise usage.
04b5967
lint fixes
95d3454
more lint fixes
0bd4016
white space problems
c3f3543
Finish styling work
7b47db3
White space error (again)
c25afd6
lint fix
69d69de
Hide modal when not in use
4b872db
Move sticky CTA to end of tab order in main
albinazs 4710e9c
Restore focus trap in iframe modals
albinazs 3ddb444
Remove iframe_modal option for non-sticky CTAs
albinazs 51fa248
Refactor modal: close icon, sr-only heading, transitions instead of a…
albinazs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
tbx/project_styleguide/templates/patterns/atoms/icon_buttons/icon_button--close.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{% extends "atoms/icon_buttons/icon_button.html" %} |
14 changes: 14 additions & 0 deletions
14
tbx/project_styleguide/templates/patterns/atoms/icon_buttons/icon_button.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<button class="icon-button{% if modifier %} icon-button--{{ modifier }}{% endif %}{% if inverse %} icon-button--inverse{% endif %}{% if hidden %} hidden{% endif %}" {% if modifier and name %}data-{{ name }}-{{ modifier }}{% endif %}{% if data %} {{ data }}{% endif %}{% if aria %} {{ aria }}{% endif %}> | ||
<span class="u-sr-only"> | ||
{% if modifier %}{{ modifier }}{% endif %} | ||
</span> | ||
{% if modifier == 'next' %} | ||
<span class="rotate">{% include "patterns/atoms/icons/icon.html" with name="chevron" %}</span> | ||
{% elif modifier == 'previous' %} | ||
<span class="rotate rotate--left">{% include "patterns/atoms/icons/icon.html" with name="chevron" %}</span> | ||
{% elif modifier == 'down' %} | ||
<span>{% include "patterns/atoms/icons/icon.html" with name="chevron" %}</span> | ||
{% elif modifier %} | ||
<span>{% include "patterns/atoms/icons/icon.html" with name=modifier %}</span> | ||
{% endif %} | ||
</button> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...ect_styleguide/templates/patterns/molecules/streamfield/blocks/sticky_call_to_action.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{% load wagtailcore_tags %} | ||
{# call_to_action is a required field (streamblock) in the block definition #} | ||
|
||
<!-- Sticky block --> | ||
<div class="call-to-action__sticky"> | ||
<div class="call-to-action__inner"> | ||
{% if value.get_button_link_block.block_type == "modal_iframe" %} | ||
<button class="call-to-action__stickybutton button" data-micromodal-trigger="iframe-embed-modal"> | ||
<span class="call-to-action__stickyheading">{{ value.sticky_text }}</span> | ||
{% if value.sticky_subtext %} | ||
<br><span class="call-to-action__stickysubtext">{{ value.sticky_subtext }}</span> | ||
{% endif %} | ||
</button> | ||
{% else %} | ||
<a href="{{ value.get_button_link }}" class="call-to-action__button button"> | ||
<span class="call-to-action__stickyheading">{{ value.sticky_text }}</span> | ||
{% if value.get_button_link_block.block_type == "document_link" %} | ||
({{ value.get_button_file_size|filesizeformat }}) | ||
{% endif %} | ||
{% if value.sticky_subtext %} | ||
<br><span class="call-to-action__stickysubtext">{{ value.sticky_subtext }}</span> | ||
{% endif %} | ||
</a> | ||
{% endif %} | ||
</div> | ||
</div> | ||
|
||
<!-- Modal content --> | ||
<div class="modal" id="iframe-embed-modal" aria-hidden="true"> | ||
<div class="modal__overlay" tabindex="-1" data-micromodal-close></div> | ||
<div class="modal__container" role="dialog" aria-modal="true" aria-labelledby="modal-title" > | ||
<header class="modal__header"> | ||
<h2 class="modal__heading heading heading--two" id="modal-title">Service Enquiry</h2> | ||
<div class="modal__close"> | ||
{% include "patterns/atoms/icon_buttons/icon_button.html" with modifier="close" data="data-micromodal-close" aria='aria-label="Close modal"' %} | ||
</div> | ||
</header> | ||
<main class="modal__content" id="filters-content"> | ||
<iframe | ||
src="{{ value.get_button_link }}" | ||
width="100%" | ||
height="650px" | ||
frameborder="0" | ||
title="Modal Webform"> | ||
</iframe> | ||
</main> | ||
</div> | ||
</div> |
7 changes: 7 additions & 0 deletions
7
...ect_styleguide/templates/patterns/molecules/streamfield/blocks/sticky_call_to_action.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
context: | ||
value: | ||
sticky_text: Get in touch | ||
sticky_subtext: learn about our journey | ||
button_link: | ||
- modal_iframe: | ||
url: 'https://example.com' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import MicroModal from 'micromodal'; // es6 module | ||
|
||
// Assumes a strcuture as follows | ||
// <div class="modal" id="filters" aria-hidden="true"> | ||
// <div class="modal__overlay" tabindex="-1" data-micromodal-close></div> | ||
// <div class="modal__container" role="dialog" aria-modal="true" aria-labelledby="modal-title" > | ||
// <header class="modal__header"> | ||
// <h2 class="modal__heading heading heading--two" id="modal-title">Title<h2> | ||
// <div class="modal__close"> | ||
// {% include "atoms/icon_buttons/icon_button.html" with modifier="close" data="data-micromodal-close" aria='aria-label="Close modal"' %} | ||
// </div> | ||
// </header> | ||
// <main class="modal__content" id="filters-content"> | ||
// Content | ||
// </main> | ||
// <footer class="modal__footer"> | ||
damwaingames marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
// <button class="modal__btn" data-micromodal-close>Close</button> | ||
// </footer> | ||
// </div> | ||
// </div> | ||
|
||
class Modal { | ||
static selector() { | ||
return '[data-micromodal-trigger]'; | ||
} | ||
|
||
constructor() { | ||
if (typeof MicroModal !== 'undefined') { | ||
MicroModal.init({ | ||
openTrigger: 'data-micromodal-trigger', | ||
disableScroll: true, | ||
}); | ||
} | ||
|
||
Modal.bindEvents(); | ||
} | ||
|
||
static bindEvents() { | ||
// Listen for clicks on the document instead of using micromodel default, which doesn't work with htmx | ||
document.body.addEventListener('click', Modal.handleEvent); | ||
document.body.addEventListener('touchstart', Modal.handleEvent); | ||
document.body.addEventListener('keydown', Modal.handleKeyDown); | ||
} | ||
|
||
static handleEvent(event) { | ||
const trigger = event.target.closest('[data-micromodal-trigger]'); | ||
if (trigger) { | ||
event.preventDefault(); | ||
event.stopPropagation(); // Stop the event from bubbling up | ||
|
||
// Get the modal ID and open the correct modal | ||
const modalId = trigger.getAttribute('data-micromodal-trigger'); | ||
if (modalId && typeof MicroModal !== 'undefined') { | ||
MicroModal.show(modalId); | ||
} | ||
} | ||
|
||
// Close modal when clicking on close buttons | ||
const closeButton = event.target.closest( | ||
'[data-micromodal-close], [data-listing-submit]', | ||
); | ||
if (closeButton) { | ||
const modal = closeButton.closest('.modal'); | ||
if (modal) { | ||
MicroModal.close(modal.id); // Close the modal | ||
document.body.style.overflow = ''; // Remove overflow hidden from body | ||
} | ||
} | ||
} | ||
|
||
// Prevent Enter from closing modal unless on button | ||
static handleKeyDown(event) { | ||
if (event.key === 'Enter') { | ||
const modal = event.target.closest('.modal'); | ||
if (modal) { | ||
// Allow Enter on buttons and prevent it on everything else | ||
if (event.target.tagName !== 'BUTTON') { | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
export default Modal; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.