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

addition of nav-item component styles and style behavior #28

Open
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

abu-seini-maf
Copy link

@carlos-verdes @moalobaidat:
NOT For Merging, only review to align on progress and approach.

const loopingBehavior = (passedNavItemParent: HTMLElement) => {
const navElementParent = passedNavItemParent;
const isMainNav =
navElementParent?.tagName?.toLocaleLowerCase() === 'mf-navigation' &&

Choose a reason for hiding this comment

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

Would you consider to rename from mf-navigation to mf-nav in a separate PR?

Copy link
Author

Choose a reason for hiding this comment

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

yes it should be renamed to mf-navigation, i'll be doing it once am back from vacation.
or someone else can pick up

Choose a reason for hiding this comment

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

You meant maf-nav right? Someone can pick up this if we are aligned with the name

private getNavItemLevel(navItemParent: HTMLElement | null) {
let level = 0;

const loopingBehavior = (passedNavItemParent: HTMLElement) => {

Choose a reason for hiding this comment

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

I read an article that discourage this kind of lambda expressions as they can cause memory leaks.
This is just a comment to share this information, no need to update the code

For reference here you can read the article: on-js-closures-and-leaks

Copy link
Author

Choose a reason for hiding this comment

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

i needed a behavior that can distinguish each level of the navigation items, to be able to style it

Choose a reason for hiding this comment

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

In the article it recommends to avoid closures, that's what is the comment about :)

Copy link

@carlos-verdes carlos-verdes left a comment

Choose a reason for hiding this comment

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

Put some comment we can discuss more later

Comment on lines +17 to +31
font-family: var(--mafui-navigationItem-font-family-primary);
font-size: var(--mafui-navigationItem-font-size-primary);
font-weight: var(--mafui-navigationItem-font-weight-primary);
line-height: var(--mafui-navigationItem-line-height-primary);
letter-spacing: var(--mafui-navigationItem-letter-spacing-primary);
color: var(--mafui-navigationItem-font-color-primary);
background-color: var(--mafui-navigationItem-color-background-primary);
border-top: var(--mafui-navigationItem-border-width-top-primary)
var(--mafui-navigationItem-border-style-top-primary) var(--mafui-navigationItem-color-border-top-primary);
border-right: var(--mafui-navigationItem-border-width-right-primary)
var(--mafui-navigationItem-border-style-right-primary) var(--mafui-navigationItem-color-border-right-primary);
border-bottom: var(--mafui-navigationItem-border-width-bottom-primary)
var(--mafui-navigationItem-border-style-bottom-primary) var(--mafui-navigationItem-color-border-bottom-primary);
border-left: var(--mafui-navigationItem-border-width-left-primary)
var(--mafui-navigationItem-border-style-left-primary) var(--mafui-navigationItem-color-border-left-primary);

Choose a reason for hiding this comment

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

I would remove -primary on the first level, for example:

font-family: var(--mafui-navigationItem-font-family);

Copy link
Author

Choose a reason for hiding this comment

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

it seems fair, as its the main style for all navigation items.
but also sounds a bit counter intuitive, lets decide on this.
@moalobaidat

Choose a reason for hiding this comment

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

My point is every menu can can levels 1, 2 and 3 (we will discourage to use more than 3 levels) and we can have more than one menu.

Each menu variant should have it's own suffix like primary, secondary etc. and each menu level it's own suffix too

Choose a reason for hiding this comment

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

Thanks for the explanation, @carlos-verdes . I get your point about using clear suffixes for consistency, but I’m not sure removing -primary from font-family is the right move. The -primary suffix helps keep things clear by showing what the default style should be, especially as we scale and maintain the code.

Maybe instead of removing it, we could look at how we’re using these suffixes and make sure they’re not confusing or redundant.

Let’s discuss further to make sure we’re keeping things both clear and easy to maintain.

Comment on lines +45 to +62
:host([level='level-1']) .nav-item {
font-family: var(--mafui-navigationItem-font-family-secondary);
font-size: var(--mafui-navigationItem-font-size-secondary);
font-weight: var(--mafui-navigationItem-font-weight-secondary);
line-height: var(--mafui-navigationItem-line-height-secondary);
letter-spacing: var(--mafui-navigationItem-letter-spacing-secondary);
color: var(--mafui-navigationItem-font-color-secondary);
background-color: var(--mafui-navigationItem-color-background-secondary);
border-top: var(--mafui-navigationItem-border-width-top-secondary)
var(--mafui-navigationItem-border-style-top-secondary) var(--mafui-navigationItem-color-border-top-secondary);
border-right: var(--mafui-navigationItem-border-width-right-secondary)
var(--mafui-navigationItem-border-style-right-secondary) var(--mafui-navigationItem-color-border-right-secondary);
border-bottom: var(--mafui-navigationItem-border-width-bottom-secondary)
var(--mafui-navigationItem-border-style-bottom-secondary)
var(--mafui-navigationItem-color-border-bottom-secondary);
border-left: var(--mafui-navigationItem-border-width-left-secondary)
var(--mafui-navigationItem-border-style-left-secondary) var(--mafui-navigationItem-color-border-left-secondary);
}

Choose a reason for hiding this comment

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

level-1 and -secondary is confusing to me, I would use level-1 for first parent and default css variables (following previous commit) and level-2 for secondary

Also I was thinking secondary is a variant and it may be useful to use it for a secondary menu (imagine a section with settings for example), so maybe is better to be explicit and use -level-2 as suffix:

:host([level='level-2']) .nav-item {
    font-family: var(--mafui-navigationItem-font-family-level-2);

Copy link
Author

Choose a reason for hiding this comment

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

LGTM, @moalobaidat ?

Comment on lines +72 to +79
border-top: var(--mafui-navigationItem-border-width-top-tertiary)
var(--mafui-navigationItem-border-style-top-tertiary) var(--mafui-navigationItem-color-border-top-tertiary);
border-right: var(--mafui-navigationItem-border-width-right-tertiary)
var(--mafui-navigationItem-border-style-right-tertiary) var(--mafui-navigationItem-color-border-right-tertiary);
border-bottom: var(--mafui-navigationItem-border-width-bottom-tertiary)
var(--mafui-navigationItem-border-style-bottom-tertiary) var(--mafui-navigationItem-color-border-bottom-tertiary);
border-left: var(--mafui-navigationItem-border-width-left-tertiary)
var(--mafui-navigationItem-border-style-left-tertiary) var(--mafui-navigationItem-color-border-left-tertiary);

Choose a reason for hiding this comment

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

not sure about having 4 variables one per border, I think is better to define the combinations we need and put an specific name:

  • all 4 borders
  • only bottom border
  • only right / left border

Copy link
Author

Choose a reason for hiding this comment

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

the specification you provided is also 4, but the one in the code provides a bit more flexibility.
lets discuss it more plz. @moalobaidat thoughts?

Choose a reason for hiding this comment

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

What do you mean?
I provided 3 options only:

  • one with all borders active, like a button
image
  • one for "stacked" elements (border-bottom by default but if we stack from bottom to top the border will be border-top)
image
  • one for inline elements, it will be right border by default and left border in RTL mode for this I haven't found any example so I think we can ommit

Choose a reason for hiding this comment

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

@abu-seini-maf - Just added my comment above

--mafui-navigationItem-font-weight-primary: var(--sl-font-weight-normal);
--mafui-navigationItem-line-height-primary: var(--sl-line-height-normal);
--mafui-navigationItem-letter-spacing-primary: var(--sl-letter-spacing-normal);
--mafui-navigationItem-font-color-primary: var(--sl-color-primary-100);
Copy link
Author

Choose a reason for hiding this comment

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

@carlos-verdes @moalobaidat will you also validate the behavior of CSS variables hierarchy:
Component Variables -> Semantic Variables -> Primitives.

Choose a reason for hiding this comment

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

For colors what I see is good enough:

--sl-color-secondary-50: var(--sl-color-green-50);

--sl-color-green-50 is the primitive and I think is self explanatory (no comments here)
--sl-color-secondary-50 this is the semantic, based on the policies I think this also fit as they mention 3 colors per site

To be discuss about fonts, in That concept store I think we have just 2, primary and secondary but I'm not sure how many variations we may have on top of that.
I'm not sure about pointing to --sl-font-mono, I think better to point to --sl-font-maint for example

For space semantics I like xs, s, m, etc.

@@ -258,6 +258,32 @@
--sl-color-primary-900: var(--sl-color-sky-900);
--sl-color-primary-950: var(--sl-color-sky-950);

/* Secondary */

Choose a reason for hiding this comment

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

I think you didn't apply changes to light.css

--mafui-navigationItem-line-height-primary: var(--sl-line-height-normal);
--mafui-navigationItem-letter-spacing-primary: var(--sl-letter-spacing-normal);
--mafui-navigationItem-font-color-primary: var(--sl-color-primary-100);
--mafui-navigationItem-color-background-primary: var(--sl-color-neutral-50);

Choose a reason for hiding this comment

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

this is pointing directly to primitive from component, I think we should point to something like --sl-color-background-primary

Comment on lines +572 to +574
--mafui-navigationItem-border-width-bottom-primary: 1px;
--mafui-navigationItem-border-style-bottom-primary: solid;
--mafui-navigationItem-color-border-bottom-primary: var(--sl-color-primary-500);

Choose a reason for hiding this comment

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

Same as before

line-height: var(--sl-line-height-normal);
letter-spacing: var(--sl-letter-spacing-normal);
color: var(--sl-color-neutral-700);
font-family: var(--mafui-navigationItem-font-family-primary);

Choose a reason for hiding this comment

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

It's a good practice to include a fallback value, especially for properties like color or font-family. Check below example:

font-family: var(--mafui-navigationItem-font-family-primary, Arial, sans-serif);

letter-spacing: var(--mafui-navigationItem-letter-spacing-primary);
color: var(--mafui-navigationItem-font-color-primary);
background-color: var(--mafui-navigationItem-color-background-primary);
border-top: var(--mafui-navigationItem-border-width-top-primary)

Choose a reason for hiding this comment

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

If the borders on all sides are meant to be the same, you can simplify this to use a shorthand border property instead of defining each side separately. Like below:

border: var(--mafui-navigationItem-border-width-primary)
var(--mafui-navigationItem-border-style-primary)
var(--mafui-navigationItem-color-border-primary);

--mafui-navigationItem-border-style-bottom-primary: solid;
--mafui-navigationItem-color-border-bottom-primary: var(--sl-color-primary-500);
--mafui-navigationItem-border-width-left-primary:;
--mafui-navigationItem-border-style-left-primary:;

Choose a reason for hiding this comment

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

Empty Variable Declarations. These variables should either be assigned meaningful values or removed if they are not yet needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants