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

Breadcrumbs #44 #213

Merged
merged 6 commits into from
Feb 15, 2024
Merged

Breadcrumbs #44 #213

merged 6 commits into from
Feb 15, 2024

Conversation

jonatan-lledo-netcentric
Copy link
Collaborator

@jonatan-lledo-netcentric jonatan-lledo-netcentric commented Feb 7, 2024

New

the breadcrumb shows or hides based on the current width, even on resizing following the design pattern:
1st Home becomes an ellipsis
2nd current Active link is hided
3rd and beyond the middle links hide from the 2nd until the very last item

Test URLs

drafts/jlledo/v2/breadcrumb-demo

Fix #44

Test URLs:

Copy link
Contributor

aem-code-sync bot commented Feb 7, 2024

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed.
In case there are problems, just click a checkbox below to rerun the respective action.

  • Re-run PSI checks
  • Re-sync branch
Commits

Copy link
Contributor

aem-code-sync bot commented Feb 7, 2024

Page Scores Audits Google
/drafts/jlledo/v2/breadcrumb-demo PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

@jonatan-lledo-netcentric jonatan-lledo-netcentric changed the title DRAFT: v2 breadcrumbs v0.0.1 DRAFT: v2 breadcrumbs Feb 7, 2024
@jonatan-lledo-netcentric jonatan-lledo-netcentric changed the title DRAFT: v2 breadcrumbs v2 breadcrumbs Feb 7, 2024
@jonatan-lledo-netcentric jonatan-lledo-netcentric changed the title v2 breadcrumbs #44 v2 breadcrumbs Feb 7, 2024
@jonatan-lledo-netcentric jonatan-lledo-netcentric marked this pull request as ready for review February 7, 2024 13:27
Copy link
Collaborator

@cogniSyb cogniSyb left a comment

Choose a reason for hiding this comment

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

As per https://www.w3.org/WAI/ARIA/apg/patterns/breadcrumb/examples/breadcrumb/ I was expecting <nav> with <ol> and <li> to be used.

Clever solution, with the observers and calculations. Do I understand correctly that the demo with flexbox was not feasible for the requirements provided?

blocks/v2-breadcrumb/v2-breadcrumb.css Show resolved Hide resolved
outline: none;
}

.v2-breadcrumb__crumb:focus,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove the selector for :focus. We only provide the focus style when the user interacts with a keyboard, via :focus-visible

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@@ -0,0 +1,55 @@
.v2-breadcrumb-wrapper{
background-color: var(--c-secondary-graphite);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree that we should use the variables. Though now that I checked, I see that #333 as color is defined for this

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I also checked it; this color doesn't yet have a proper variable. the other Figma file uses this color. updated

outline-offset: 2px
}

.v2-breadcrumb__crumb:not(.v2-breadcrumb__crumb--home)::before {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I’d rather see ::before as part of an <li> so that it isn’t clickable.

The selector could be .v2-breadcrumb__crumb + .v2-breadcrumb__crumb::before, which is easier to read and more maintainable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it works the same than the use of :not(), so done

const sectionStatus = 'data-section-status';
const homeText = {
home: 'home',
ellipsis: '...',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rather use a true ellipsis, which is one character. See https://practicaltypography.com/ellipses.html

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I didn't know about a single character for this. done

block.textContent = '';
block.append(...crumbs);
block.parentElement.classList.add('full-width');
block.setAttribute('aria-label', 'Breadcrumb');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use getTextLabel, this content should be configurable in case of other languages

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

placeholder updated. done

export default function decorate(block) {
const cfg = readBlockConfig(block);
const hasPath = cfg && Object.hasOwn(cfg, 'path');
const url = new URL(window.location.href);
Copy link
Collaborator

Choose a reason for hiding this comment

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

As we’re not manipulating window.location, but rather reading contents of it, wouldn’t the following be easier?

let hasPath = cfg && Object.hasOwn(cfg, 'path');
let url = hasPath ? cfg.path : window.location.pathname;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

is shorter and I like it, so done

ellipsis: '...',
};

const removePathDash = (str) => str.replace(/-/g, ' ').toLowerCase();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here you’re doing more than removing the dash from the path. You’re also transforming text to lowercase. So, could we rename it to formatText?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

agree, done

return blockWidth - padding;
};

const areCrumbsFit = (block) => getCrumbsWidth(block) < getBlockWidth(block);
Copy link
Collaborator

Choose a reason for hiding this comment

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

areCrumbsFit confused me a bit. I think doCrumbsFit or even fitting would be clearer

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I like fitting, so done

homeEl.textContent = homeText.home;
crumbs.forEach((crumb, i) => {
if (i === 0) return;
crumb.textContent = crumb.dataset.content;
Copy link
Collaborator

Choose a reason for hiding this comment

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

These two lines are easier if it’s written like this:

if (index > 0) crumb.textContent = crumb.dataset.content;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

}

.v2-breadcrumb {
padding: 18px 16px 14px;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should just do padding: 16px instead. At the 1200px breakpoint we should get rid of the horizontal padding, for alignment

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@cogniSyb cogniSyb added the FR Functional requirement label Feb 8, 2024
@cogniSyb cogniSyb changed the title #44 v2 breadcrumbs Breadcrumbs #44 Feb 8, 2024
@jonatan-lledo-netcentric
Copy link
Collaborator Author

As per https://www.w3.org/WAI/ARIA/apg/patterns/breadcrumb/examples/breadcrumb/ I was expecting <nav> with <ol> and <li> to be used.

I added the nav and ul/li elements to follow the a11y pattern

Clever solution, with the observers and calculations. Do I understand correctly that the demo with Flexbox was not feasible for the requirements provided?

the example removes all the elements from the end of the list and this doesn't work for our needs

@cogniSyb cogniSyb merged commit 636c424 into develop Feb 15, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FR Functional requirement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants