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

MWPW-129922 - Action Blocks & Expanded Section Ups Capabilities #1022

Closed
wants to merge 106 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
bed8311
section grid support, action item and slider blocks
Sartxi Jul 25, 2023
52a2675
use item width for actions in slider
Sartxi Jul 25, 2023
d9abb91
media breakpoint max
Sartxi Jul 25, 2023
96e286e
action scroller
Sartxi Jul 26, 2023
7ff22f7
item width override
Sartxi Jul 26, 2023
5ca430a
action items and scroller block unit tests
Sartxi Jul 26, 2023
e901543
fix error from import
Sartxi Jul 26, 2023
afb6be2
cleanup
Sartxi Jul 27, 2023
3509537
cleanup
Sartxi Jul 27, 2023
2df32ba
center margin style
Sartxi Jul 27, 2023
ee1a6ce
Merge branch 'main' into sarchibeque/actions
Sartxi Jul 27, 2023
2d51196
Update libs/blocks/section-metadata/section-metadata.js
Sartxi Jul 27, 2023
fe8ced4
Update libs/blocks/section-metadata/section-metadata.js
Sartxi Jul 27, 2023
d0f684b
Update libs/blocks/action-scroller/action-scroller.js
Sartxi Jul 27, 2023
41d1fa6
Update libs/blocks/action-scroller/action-scroller.js
Sartxi Jul 27, 2023
cbc8f5b
Update libs/blocks/action-scroller/action-scroller.js
Sartxi Jul 27, 2023
2344fbc
git bot reviews
Sartxi Jul 27, 2023
2fc64c3
remove vscode settings
Sartxi Jul 27, 2023
ecd2930
Update libs/blocks/action-item/action-item.js
Sartxi Jul 27, 2023
75990bc
Update libs/blocks/action-item/action-item.js
Sartxi Jul 27, 2023
ea77e73
remove comment
Sartxi Jul 27, 2023
4aad251
update image size options
Sartxi Jul 27, 2023
a5f1c7a
update float icon position
Sartxi Jul 27, 2023
03609f7
icon size update
Sartxi Jul 27, 2023
d1a03e0
Merge branch 'main' into sarchibeque/actions
Sartxi Jul 28, 2023
377d60e
Minor refactor using `mask-image` for the scrolling fade feature
ryanmparrish Jul 28, 2023
23dedd2
uneeded style
Sartxi Jul 28, 2023
ff5a590
zoom and focus cleanup
Sartxi Jul 28, 2023
bd006ee
line up with master fix conflict
Sartxi Aug 1, 2023
621baa1
Merge branch 'main' into sarchibeque/actions
Sartxi Aug 1, 2023
c23da02
update to use focus visible selector instead of focus
Sartxi Aug 1, 2023
6c78890
focus use outline instead of border
Sartxi Aug 1, 2023
8fa1b45
support static links
Sartxi Aug 1, 2023
bbc0654
static links variant
Sartxi Aug 1, 2023
0746051
scroller nav focus style
Sartxi Aug 1, 2023
79de8ab
cleanup
Sartxi Aug 1, 2023
065c0fb
Merge branch 'main' into sarchibeque/actions
Sartxi Aug 2, 2023
06e1e7a
dial in focus styles and add missing section spacing style
Sartxi Aug 2, 2023
da688bc
Merge branch 'sarchibeque/actions' of https://github.com/adobecom/mil…
Sartxi Aug 2, 2023
b9ef7fe
Update libs/blocks/action-item/action-item.css
Sartxi Aug 2, 2023
14646dd
Update libs/blocks/action-scroller/action-scroller.css
Sartxi Aug 2, 2023
92f1f27
Update libs/blocks/section-metadata/section-metadata.js
Sartxi Aug 2, 2023
261c675
Update test/blocks/action-scroller/mocks/body.html
Sartxi Aug 2, 2023
79bf37a
Update test/blocks/action-item/mocks/body.html
Sartxi Aug 2, 2023
15ec5e0
Merge branch 'main' into sarchibeque/actions
Sartxi Aug 3, 2023
d9d7257
update action scroller test
Sartxi Aug 3, 2023
6b791d9
section metadata autoup code cov
Sartxi Aug 3, 2023
1041ea0
Update test/blocks/section-metadata/section-meta.test.js
Sartxi Aug 3, 2023
52eaa3f
action scroller test converage
Sartxi Aug 3, 2023
fd4dae9
Update test/blocks/action-scroller/action-scroller.test.js
Sartxi Aug 3, 2023
49cd823
Update test/blocks/action-scroller/action-scroller.test.js
Sartxi Aug 3, 2023
e46cb9f
decorate links
Sartxi Aug 9, 2023
588958d
line up with main and fix conflicts
Sartxi Aug 9, 2023
7ad10a8
fix links and testing
Sartxi Aug 9, 2023
42374a0
action item test coverage
Sartxi Aug 9, 2023
f13819f
use some instead of find index to setup auto ups
Sartxi Aug 10, 2023
5a30d48
Update libs/blocks/section-metadata/section-metadata.js
Sartxi Aug 10, 2023
fd3d6bd
prevent type error in handle float functions
Sartxi Aug 10, 2023
8bb1a95
Merge branch 'sarchibeque/actions' of https://github.com/adobecom/mil…
Sartxi Aug 10, 2023
a1cf93f
update files to adhere to line length under 100 chars
Sartxi Aug 10, 2023
10f4fb9
Update libs/blocks/action-scroller/action-scroller.js
Sartxi Aug 10, 2023
b0b1a27
Update libs/blocks/action-scroller/action-scroller.js
Sartxi Aug 10, 2023
f6da2a0
Update libs/blocks/action-scroller/action-scroller.js
Sartxi Aug 10, 2023
18571b9
Update libs/blocks/action-scroller/action-scroller.js
Sartxi Aug 10, 2023
19fa7db
Update libs/blocks/action-scroller/action-scroller.js
Sartxi Aug 10, 2023
1362a4d
Update libs/blocks/action-scroller/action-scroller.js
Sartxi Aug 10, 2023
e8f9c3a
Update libs/blocks/section-metadata/section-metadata.js
Sartxi Aug 10, 2023
ff50822
Update libs/blocks/section-metadata/section-metadata.js
Sartxi Aug 10, 2023
9f5ecb7
Update libs/blocks/section-metadata/section-metadata.js
Sartxi Aug 10, 2023
fb93e8f
Update libs/blocks/section-metadata/section-metadata.js
Sartxi Aug 10, 2023
75bc354
Update libs/blocks/section-metadata/section-metadata.js
Sartxi Aug 10, 2023
c58acb7
Update libs/blocks/action-scroller/action-scroller.js
Sartxi Aug 10, 2023
cbb386d
Update libs/blocks/action-scroller/action-scroller.js
Sartxi Aug 10, 2023
dfa6334
Update libs/blocks/action-scroller/action-scroller.js
Sartxi Aug 10, 2023
4c8d166
Update libs/blocks/action-scroller/action-scroller.js
Sartxi Aug 10, 2023
760c219
Update libs/blocks/section-metadata/section-metadata.js
Sartxi Aug 10, 2023
dde301e
Update libs/blocks/action-scroller/action-scroller.js
Sartxi Aug 10, 2023
f96adee
Update libs/blocks/action-scroller/action-scroller.js
Sartxi Aug 10, 2023
d92bf23
Update libs/blocks/action-scroller/action-scroller.js
Sartxi Aug 10, 2023
afc6bc8
Update libs/blocks/action-scroller/action-scroller.js
Sartxi Aug 10, 2023
a2a4c84
Update libs/blocks/section-metadata/section-metadata.js
Sartxi Aug 10, 2023
2e4b590
Update libs/blocks/section-metadata/section-metadata.js
Sartxi Aug 10, 2023
f27fb42
Update libs/blocks/section-metadata/section-metadata.js
Sartxi Aug 10, 2023
8155169
Update libs/blocks/section-metadata/section-metadata.js
Sartxi Aug 10, 2023
c9076a7
Update libs/blocks/section-metadata/section-metadata.js
Sartxi Aug 10, 2023
6e58871
Update libs/blocks/section-metadata/section-metadata.js
Sartxi Aug 10, 2023
d78b927
Merge branch 'main' into sarchibeque/actions
Sartxi Aug 10, 2023
ac6f2eb
Update libs/blocks/section-metadata/section-metadata.js
Sartxi Aug 10, 2023
f8e61b3
Update libs/blocks/section-metadata/section-metadata.js
Sartxi Aug 10, 2023
82b3b86
Update libs/blocks/action-scroller/action-scroller.js
Sartxi Aug 10, 2023
90c550b
Update libs/blocks/action-scroller/action-scroller.js
Sartxi Aug 10, 2023
68df668
Update libs/blocks/action-scroller/action-scroller.js
Sartxi Aug 10, 2023
c960203
Update libs/blocks/action-scroller/action-scroller.js
Sartxi Aug 10, 2023
6f3b731
Update libs/blocks/action-scroller/action-scroller.js
Sartxi Aug 10, 2023
e9cac7a
Update libs/blocks/action-scroller/action-scroller.js
Sartxi Aug 10, 2023
321d793
Update libs/blocks/section-metadata/section-metadata.js
Sartxi Aug 10, 2023
a817728
Update libs/blocks/section-metadata/section-metadata.js
Sartxi Aug 10, 2023
eef5e23
Update libs/blocks/action-scroller/action-scroller.js
Sartxi Aug 10, 2023
67348da
Update libs/blocks/section-metadata/section-metadata.js
Sartxi Aug 10, 2023
96d79a9
adjust float button to use consistent authoring pattern
Sartxi Aug 10, 2023
aafcdc5
Update libs/blocks/action-scroller/action-scroller.js
Sartxi Aug 10, 2023
52d4ae0
adjust for new item float button authoring
Sartxi Aug 10, 2023
6860dde
Merge branch 'main' into sarchibeque/actions
Sartxi Aug 14, 2023
fa65a24
remove copyright comments
Sartxi Aug 15, 2023
5edc30c
Merge branch 'sarchibeque/actions' of https://github.com/adobecom/mil…
Sartxi Aug 15, 2023
1995bab
use if else instead of switch in sticky sections
Sartxi Aug 15, 2023
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
145 changes: 145 additions & 0 deletions libs/blocks/action-item/action-item.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
.action-item img {
display: block;
max-height: 240px;
}

.action-item.inline {
display: inline-block;
width: auto;
}

.action-item.float-button .main-image picture::after {
content: '';
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
background: linear-gradient(180deg, rgba(0 0 0 / 0%) 40%, rgba(0 0 0 / 100%) 100%);
}

.action-item.rounded img,
.action-item.rounded .main-image picture:not(.floated-icon),
.action-item.rounded.float-button .main-image picture::after {
border-radius: 4px;
overflow: hidden;
}

.action-item.rounded-l img,
.action-item.rounded-l .main-image picture:not(.floated-icon),
.action-item.rounded-l.float-button .main-image picture::after {
border-radius: 16px;
overflow: hidden;
}

.action-item.center {
text-align: center;
margin: 0 auto;
}

.action-item.center img {
margin: 0 auto;
}

.action-item.small {
font-size: var(--type-body-xs-size);
}

.action-item.small img {
min-height: var(--spacing-xl);
}

.action-item.medium {
font-size: var(--type-body-s-size);
}

.action-item.medium img {
min-height: var(--spacing-xxl);
}

.action-item.large {
font-size: var(--type-body-m-size);
}

.action-item.large img {
min-height: var(--spacing-xxxl);
}

.action-item.image-size-small img {
max-height: var(--spacing-xl);
}

.action-item.image-size-medium img {
max-height: var(--spacing-xxl);
}

.action-item.image-size-large img {
max-height: var(--spacing-xxxl);
}

.action-item.float-icon .floated-icon img {
width: 24px;
height: 24px;
align-self: center;
}

.action-item.zoom {
display: flex;
}

.action-item.zoom .main-image {
flex-grow: 1;
position: relative;
}

.action-item.zoom .main-image picture:not(.floated-icon) {
display: block;
}

.action-item.float-button .main-image picture img {
min-width: 100%;
}

.action-item.zoom .main-image picture:not(.floated-icon) img {
object-fit: cover;
will-change: transform;
transition: transform .2s ease;
}

.action-item:not(.zoom) a:focus-visible picture:not(.floated-icon) img,
.action-item.zoom a:focus-visible picture:not(.floated-icon) {
outline-color: -webkit-focus-ring-color;
outline-style: auto;
}

.action-item a:not(.con-button):focus-visible {
outline: none;
text-decoration: underline;
}

.action-item.zoom .main-image picture:not(.floated-icon) img:hover {
transform: scale(1.05);
}

.action-item.float-icon .floated-icon {
display: flex;
position: absolute;
bottom: -9px;
right: -19px;
background-color: black;
border-radius: 50%;
height: 40px;
width: 40px;
}

.action-item.float-button .main-image {
position: relative;
}

.action-item.float-button .con-button {
position: absolute;
z-index: 1;
left: 50%;
bottom: 0;
transform: translate(-50%, -50%);
}
56 changes: 56 additions & 0 deletions libs/blocks/action-item/action-item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { decorateButtons } from '../../utils/decorate.js';
import { createTag } from '../../utils/utils.js';

function getLayout(elems) {
const link = elems.length > 1 ? elems[elems.length - 1] : null;
return { foreground: elems[0], link };
}

function handleFloatIcon(picture, icon) {
if (!picture || !icon) return;
icon.classList.add('floated-icon');
picture.appendChild(icon);
}

function handleFloatBtn(picture, content) {
if (!picture || !content) return;
decorateButtons(content);
const btn = content.querySelector('.con-button');
if (!btn) return;
picture.classList.add('dark');
picture.appendChild(btn);
}

function decorateLink(link) {
const anchor = link.querySelector('a');
let attrs = { href: anchor.href };
if (attrs.href.includes('#_blank') || anchor.target === '_blank') {
attrs.href = anchor.href.replace('#_blank', '');
attrs = { ...attrs, target: '_blank' };
}
return attrs;
}

function getContent(el, variants, link) {
const pictures = el.querySelectorAll('picture');
const text = el.querySelector('h1, h2, h3, h4, h5, h6, p')?.closest('div');
const mainPic = pictures[0];
const picture = mainPic?.parentElement;
picture?.classList.add('main-image');
chrischrischris marked this conversation as resolved.
Show resolved Hide resolved
const wrapLink = link && !variants.contains('float-button');
const tag = wrapLink ? 'a' : 'div';
let attrs = wrapLink ? decorateLink(link) : {};
if (variants.contains('float-icon')) handleFloatIcon(picture, pictures[1]);
if (variants.contains('float-button')) handleFloatBtn(picture, link);
if (variants.contains('static-links')) attrs = { ...attrs, class: 'static' };
const content = createTag(tag, { ...attrs }, text ?? picture);
Sartxi marked this conversation as resolved.
Show resolved Hide resolved
return content;
}

export default function init(el) {
const elems = el.querySelectorAll(':scope > div');
if (!elems.length) return;
const { foreground, link } = getLayout(elems);
const content = getContent(foreground, el.classList, link);
el.replaceChildren(content);
}
147 changes: 147 additions & 0 deletions libs/blocks/action-scroller/action-scroller.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
.action-scroller {
--action-scroller-mobile-padding: 50px;
--action-scroller-button-color: white;
--action-scroller-button-size: 32px;
--action-scroller-button-border-color: #646364;
--action-scroller-button-border-color-hover: #333;
--action-scroller-column-width: calc(var(--action-scroller-item-width) * 1px);

display: block;
position: relative;
}

.action-scroller .section.scrolling {
display: grid;
grid-template-columns: repeat(var(--action-scroller-columns), 1fr);
grid-auto-columns: minmax(var(--action-scroller-column-width), 1fr);
grid-auto-flow: column;
padding: 0 var(--action-scroller-mobile-padding);
overflow-x: auto;
-ms-overflow-style: none;
scrollbar-width: none;
scroll-behavior: smooth;

--mask-width: 60px;
--mask-image-content: linear-gradient(to right,
transparent,
black var(--mask-width),
black calc(100% - var(--mask-width)),
transparent);
--mask-size-content: 100% 100%;
--mask-image-scrollbar: linear-gradient(black, black);
--mask-size-scrollbar: 0 100%;

/* stylelint-disable property-no-vendor-prefix */
-webkit-mask-image: var(--mask-image-content), var(--mask-image-scrollbar);
-webkit-mask-size: var(--mask-size-content), var(--mask-size-scrollbar);
-webkit-mask-position: 0 0, 100% 0;
-webkit-mask-repeat: no-repeat, no-repeat;
-moz-mask-image: var(--mask-image-content), var(--mask-image-scrollbar);
-moz-mask-size: var(--mask-size-content), var(--mask-size-scrollbar);
-moz-mask-position: 0 0, 100% 0;
-moz-mask-repeat: no-repeat, no-repeat;
/* stylelint-enable property-no-vendor-prefix */
Comment on lines +34 to +43
Copy link
Contributor

Choose a reason for hiding this comment

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

What browsers are this for? We support the last 2 evergreen versions so I don't think any of this is needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is to support the faded edges when an action-item is overflowing in a scrolling area.
I tested this on a few browsers and wasn't seeing these work w/ out the browser prefixes.
Correct me if i'm wrong but I thought these are needed for newer css properties like mask-image?


mask-image: var(--mask-image-content), var(--mask-image-scrollbar);
mask-size: var(--mask-size-content), var(--mask-size-scrollbar);
mask-position: 0 0, 100% 0;
mask-repeat: no-repeat, no-repeat;
}


.action-scroller .section.scrolling::-webkit-scrollbar {
display: none;
}

.action-scroller .section.scrolling .action-item {
width: var(--action-scroller-column-width);
}

.action-scroller .nav-grad {
position: absolute;
height: 100%;
width: 54px;
top: 0;
}

.action-scroller .nav-grad.next {
right: 0;
}

.action-scroller .nav-grad.previous {
left: 0;
}

.action-scroller .nav-grad[hide-btn='true'] {
display: none;
}

.action-scroller .previous-button,
.action-scroller .next-button {
display: flex;
position: absolute;
align-items: center;
justify-content: center;
cursor: pointer;
outline: none;
border-radius: 100%;
border-style: solid;
border-width: 1px;
background-color: var(--action-scroller-button-color);
border-color: var(--action-scroller-button-border-color);
height: var(--action-scroller-button-size);
width: var(--action-scroller-button-size);
top: calc(50% - var(--action-scroller-button-size) / 2);
z-index: 2;
}

.action-scroller .next-button {
right: 10px;
}

.action-scroller .previous-button {
left: 10px;
}

.action-scroller.grid-align-end .previous-button,
.action-scroller.grid-align-end .next-button {
top: calc(55% - var(--action-scroller-button-size) / 2);
}

.action-scroller .nav-grad .next-button:focus,
.action-scroller .nav-grad .previous-button:focus {
outline-color: -webkit-focus-ring-color;
outline-style: auto;
}

.action-scroller .nav-button:hover,
.action-scroller .nav-button:focus,
.action-scroller .nav-button:active {
background-color: var(--action-scroller-button-color);
border-color: var(--action-scroller-button-border-color-hover);
outline: none;
}

.action-scroller .nav-button img {
height: 16px;
width: 10px;
margin-left: 2px;
}

.action-scroller .previous-button img {
margin-right: 3px;
transform: rotate(180deg);
}

.action-scroller .nav-button:hover img,
.action-scroller .nav-button:focus img,
.action-scroller .nav-button:active img {
filter: brightness(0) saturate(100%);
}

@media screen and (min-width: 1200px) {
.action-scroller {
width: var(--grid-container-width);
margin: 0 auto;
}
}
Loading
Loading