-
Notifications
You must be signed in to change notification settings - Fork 101
feat(user card) - Update User Card to SHINE styles (part 2) #2123
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
base: beta
Are you sure you want to change the base?
Conversation
giamir
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Tavian for the PR. As you can see I am asking for few changes. Hopefully they are all understandable if not let me know and we can pair.
For the svelte component I suggest to create a UserCardAdditionalBling subcomponent so that we don't have to add a lot of logic and props in the existing root UserCard component but just a snippet.
Sidenote
I think AdditionalBling is a pretty poor name to describe the little extra icons that can be added to between the badges and the blings but it is what we have in Figma so I guess we can roll with it. I don't have a better name for now. cc @CGuindon
| &:before { | ||
| height: var(--_ba-before-h); | ||
| margin-top: 0; | ||
| margin-left: calc(var(--su2) * -1); // -2px margin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have --sun2 now after Dan's PR got merged
| color: var(--black-400); | ||
| } | ||
|
|
||
| & &--original-poster { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this should be named s-user-card--username__op? cc @dancormier
| word-break: break-all; | ||
| } | ||
|
|
||
| & &--awarded-third { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are those used? I cannot find them in the docs snippets?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's used to set the colors for the additional bling trophies. It's used in the awarded snippet like so
<div class="s-user-card--group s-user-card--awarded-third" title="…" data-controller="s-tooltip"> @Svg.Icon.AchievementsSm.With("native") </div>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for clarifying. I would like to get @dancormier opinions on the API naming here. There is a part of me that still wonder if this "additional blings" are worthy to be included already in the central library or we should just have the consumer define them for now and only centralize when we see the pattern is used across several scenarios (not just collectives). What I mean is that instead of creating a s-user-card--awarded-third class to add just the color consumers could use atomic color classes and take care of it themselves (we could still keep an example in the docs but we won't have any dedicated less). The equivalent in the svelte component world would be just to have a snippet (e.g. additionalBlings - it would be nice to find a better name but it is what it is) to plug things in it but also there we will allow consumers to pass in it whatever they want.
Also cc @CGuindon for visibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way what I am suggesting is some version of the last responsible moment. Do we have enough confidence to nail the API at this stage, with the information and the use case we have or is it better to keep things flexible for the time being and defer centralization of some styling to a later moment.
| color: var(--black-400); | ||
| } | ||
|
|
||
| & &--original-poster { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| import Popover from "../Popover/Popover.svelte"; | ||
| import PopoverReference from "../Popover/PopoverReference.svelte"; | ||
| import PopoverContent from "../Popover/PopoverContent.svelte"; | ||
| import avatarDeleted16 from "../../assets/img/avatar-deleted-16.svg?url"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this inline the asset otherwise it won't work after things get bundled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could probably create an AvatarDeleted16.svelte and an AvatarDeleted24.svelte components in the UserCard folder for now with the svg in it.
| {@render badges()} | ||
| </ul> | ||
| {/if} | ||
| {#if award} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we would be better off to create UserCardAdditionalBling subcomponent here for consumer to use. We are inferring too much from the value of award (tooltip text, class, etc...). And then just have a additionalBling snippet in the root UserCard component.
|
|
||
| {#snippet userCardMainContent()} | ||
| {@render avatarAndName()} | ||
| {#if recognition && size === "sm"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need recognitionHref?
Can we actually make the UserCardAdditionalBling subcomponent generic so that the consumer can decide if they want to show the "little cup icon" bling or the "recognition icon" bling instead? It would be nice to keep the additions on the UserCard.svelte component to a minimum. As I said in a previous comment maybe just a additionalBling (or additionalBlings) snippet depending if more than one bling can be displayed together or not. Keep things generic and then have any additional logic in the UserCardAdditionalBling subcomponent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| }, | ||
| { | ||
| "name": "New Contributor", | ||
| "class": "s-user-card--new-contributor", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class does not exist in less, we should probably remove it from the docs and the examples
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ttaylor-stack it looks like there are still references of the s-user-card--new-contributor class across the codebase, Maybe you want to do an old fashion CTRL+F and make sure everything is cleaned up. Thank you. 🙂
| <svelte:element | ||
| this={recognitionHref ? "a" : "div"} | ||
| href={recognitionHref} | ||
| class="s-user-card--group s-user-card--recognition" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same s-user-card--recognition is used for 2 purposes:
- for the container element "Recognized by..."
- for the recognition icon in the additional blings section
I think this is confusing, we are probably better off create another class for the additional blings part
| </ul> | ||
| {/if} | ||
| {#if award} | ||
| <Popover id="user-card-award-popover" tooltip> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
popover ids need to be unique for the whole page so if we generate them inside svelte we need to either create a random text we can append to them or ask the consumer to do that
| --_uc-username-d: flex; | ||
| --_uc-username-ai: center; | ||
| .s-user-card__sm & { | ||
| --_uc-username-p: 0px var(--su4); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: incorrect indentation and px (unit of measure) not necessary
packages/stacks-svelte/package.json
Outdated
| "test:watch": "npm run build:dependencies && web-test-runner --watch", | ||
| "test:tools": "npm run storybook:build && node --test tools/*.test.js", | ||
| "storybook": "storybook dev -p 6006", | ||
| "storybook": "npm run build:dependencies && storybook dev -p 6006", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this bit @ttaylor-stack? We shouldn't need it since the less files of stacks classic are compiled on the fly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was getting this error [ERROR] Failed to resolve entry for package "@stackoverflow/stacks-utils". The package may have incorrect main/module/exports specified in its package.json. [plugin vite:dep-scan]
I've removed it and it seems to be working atm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was actually suggesting something dumber than this. HTML (like SVGs) are valid svelte component. So AvatarDeleted16.svelte would basically be as simple as:
<svg ...>
...source code now under `assets/img` folder
</svg>If you prefer we could name the component AvatarDeleted16Svg.svelte or AvatarDeleted16Raw.svelte but it does not really matter since they are internal only to the UserCard. Nothing else can or should use it for now.
That way we don't need to create an assets folder at all for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should sync about this. Perhaps I don't fully see all limitations/issues we would have with the approach I am suggesting.
| /** | ||
| * Unique id for the popover | ||
| */ | ||
| popoverId: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to call this popoverId, we just need an id for the component and should only knows that. That we use that for a popover internally is an implementation detail. 🙂
| icon: string; | ||
| /** | ||
| * href for the link to leaderboard or collective landing page |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the description should be more generic
link for the additional bling element (e.g. leaderboard or collective landing page)
| /** | ||
| * Snippet used to display user bio | ||
| * Snippet used to display user recognized member |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need a dedicated snippet for the recognized member bling? Can everything fall under the additionalBlings snippet umbrella?
It looks like all additionalBlings are always rendered after the badges according to figma

At the moment it seems we are placing the recognized member one before the badges snippet which should not be the case. I think one more reason to have a single snippet called additionalBlings.
…m/StackExchange/Stacks into spark-127/update-user-card-part-2



SPARK-127
Figma
This PR covers part 2 of the User Card component which includes: