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

feat(dropdown-item): update spacing of icons #9330

Merged
merged 8 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,38 +1,35 @@
.container--s {
@apply text-n2h py-1;
padding-inline-end: theme("padding.2");
padding-inline-start: theme("padding.6");
:host([scale="s"]) {
.container {
jcfranco marked this conversation as resolved.
Show resolved Hide resolved
@apply text-n2h py-1 px-2;
}
}

.container--m {
@apply text-n1h py-2;
padding-inline-end: theme("padding.3");
padding-inline-start: theme("padding.8");
:host([scale="m"]) {
.container {
@apply text-n1h py-2 px-3;
}
}

.container--l {
@apply text-0h py-2.5;
padding-inline-end: theme("padding.4");
padding-inline-start: theme("padding.10");
:host([scale="l"]) {
.container {
@apply text-0h py-2.5 px-4;
}
}

// none-selection mode
.container--s.container--none-selection {
padding-inline-start: theme("padding.1");
& .dropdown-link {
padding-inline-start: theme("padding.0");
}
}

.container--m.container--none-selection {
padding-inline-start: theme("padding.2");
& .dropdown-link {
padding-inline-start: theme("padding.0");
}
}

.container--l.container--none-selection {
padding-inline-start: theme("padding.3");
& .dropdown-link {
padding-inline-start: theme("padding.0");
}
Expand Down Expand Up @@ -64,8 +61,6 @@

.dropdown-item-content {
@apply flex-auto py-0.5;
padding-inline-end: theme("margin.auto");
padding-inline-start: theme("margin.1");
}

//focus
Expand Down Expand Up @@ -132,23 +127,23 @@

// item icon
.dropdown-item-icon {
@apply absolute
@apply relative
opacity-0
duration-150
ease-in-out;
transform: scale(0.9);
}

.container--s .dropdown-item-icon {
inset-inline-start: theme("spacing.1");
padding-inline-end: 8px;
}

.container--m .dropdown-item-icon {
inset-inline-start: theme("spacing.2");
padding-inline-end: 12px;
}

.container--l .dropdown-item-icon {
inset-inline-start: theme("spacing.3");
padding-inline-end: 16px;
}

:host(:hover:not([disabled])) .dropdown-item-icon {
Expand All @@ -164,31 +159,28 @@
// icon start & end
.container--s {
.dropdown-item-icon-start {
margin-inline-end: theme("margin.2");
margin-inline-start: theme("margin.1");
padding-inline-end: 8px;
}
.dropdown-item-icon-end {
margin-inline-start: theme("margin.2");
padding-inline-start: 8px;
}
jcfranco marked this conversation as resolved.
Show resolved Hide resolved
}

.container--m {
.dropdown-item-icon-start {
margin-inline-end: theme("margin.3");
margin-inline-start: theme("margin.1");
padding-inline-end: 12px;
}
.dropdown-item-icon-end {
margin-inline-start: theme("margin.3");
padding-inline-start: 12px;
}
}

.container--l {
.dropdown-item-icon-start {
margin-inline-end: theme("margin.4");
margin-inline-start: theme("margin.1");
padding-inline-end: 16px;
}
.dropdown-item-icon-end {
margin-inline-start: theme("margin.4");
padding-inline-start: 16px;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class DropdownItem implements InteractiveComponent, LoadableComponent {
*
* @internal
*/
@Prop() scale: Scale = "m";
@Prop({ reflect: true }) scale: Scale = "m";
Copy link
Member

Choose a reason for hiding this comment

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

Per our conversation, let's discuss reflection of internal properties as a pattern, as it simplifies styling without significant trade-offs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reflecting @internal props for styling purposes will help us improves the maintainability and readability of styles. Though it's internal since they aren't document for public use it is safe to reflect and take advantage of the attribute selector in CSS instead of creating dynamic classes.

Considering this PR as example, reflecting prop helped us avoid cumbersome styling code and there are other instance in the repo where internal props are reflected. We can use this as a pattern if the reflection helps improving the code without affecting UI/UX.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah its a trade off discussion...

Is showing an undocumented attribute terrible? No.
Is not showing an undocumented attribute better? Probably.

So its really about if its worth the work to use an internal shadow DOM class vs relying on an attribute.

Copy link
Member

Choose a reason for hiding this comment

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

So its really about if its worth the work to use an internal shadow DOM class vs relying on an attribute.

Agreed. From what I've seen, the extra work of adding root container classes to mimic host and reflected internal attributes (e.g., scale-related styling) can feel like overkill. Since we usually avoid reflecting props on the host element, leveraging the reflection of internal properties seems simpler and cleaner in this case.


//--------------------------------------------------------------------------
//
Expand Down
Loading