Skip to content

Commit 082d782

Browse files
committed
💄 Fix User alignment in flex containers
1 parent df044be commit 082d782

3 files changed

Lines changed: 49 additions & 36 deletions

File tree

src/blocks/User/User.astro

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
import {
33
Avatar,
4+
ConditionalWrapper,
45
Rating
56
} from 'webcoreui/astro'
67
@@ -19,21 +20,26 @@ const {
1920
} = Astro.props
2021
---
2122

22-
<div class="flex sm items-center">
23-
<Avatar
24-
img={avatar}
25-
size={avatarSize}
26-
/>
27-
<div class="flex column xs">
28-
<span>{name}</span>
29-
{role && (
30-
<span class="muted" data-tooltip={roleTooltip}>
31-
{role}
32-
</span>
33-
)}
23+
<ConditionalWrapper condition={!!rating}>
24+
<div slot="wrapper">children</div>
25+
26+
<div class="flex sm items-center">
27+
<Avatar
28+
img={avatar}
29+
size={avatarSize}
30+
/>
31+
<div class="flex column xs">
32+
<span>{name}</span>
33+
{role && (
34+
<span class="muted" data-tooltip={roleTooltip}>
35+
{role}
36+
</span>
37+
)}
38+
</div>
3439
</div>
35-
</div>
36-
{rating && (
37-
<hr />
38-
<Rating {...rest} score={rating} />
39-
)}
40+
{rating && (
41+
<hr />
42+
<Rating {...rest} score={rating} />
43+
)}
44+
</ConditionalWrapper>
45+

src/blocks/User/User.svelte

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script lang="ts">
22
import {
33
Avatar,
4+
ConditionalWrapper,
45
Rating
56
} from 'webcoreui/svelte'
67
@@ -17,21 +18,23 @@
1718
}: UserProps = $props()
1819
</script>
1920

20-
<div class="flex sm items-center">
21-
<Avatar
22-
img={avatar}
23-
size={avatarSize}
24-
/>
25-
<div class="flex column xs">
26-
<span>{name}</span>
27-
{#if role}
28-
<span class="muted" data-tooltip={roleTooltip}>
29-
{role}
30-
</span>
31-
{/if}
21+
<ConditionalWrapper condition={!!rating}>
22+
<div class="flex sm items-center">
23+
<Avatar
24+
img={avatar}
25+
size={avatarSize}
26+
/>
27+
<div class="flex column xs">
28+
<span>{name}</span>
29+
{#if role}
30+
<span class="muted" data-tooltip={roleTooltip}>
31+
{role}
32+
</span>
33+
{/if}
34+
</div>
3235
</div>
33-
</div>
34-
{#if rating}
35-
<hr />
36-
<Rating {...rest} score={rating} />
37-
{/if}
36+
{#if rating}
37+
<hr />
38+
<Rating {...rest} score={rating} />
39+
{/if}
40+
</ConditionalWrapper>

src/blocks/User/User.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react'
22
import {
33
Avatar,
4+
ConditionalWrapper,
45
Rating
56
} from 'webcoreui/react'
67

@@ -17,7 +18,10 @@ const User = ({
1718
}: UserProps) => {
1819

1920
return (
20-
<React.Fragment>
21+
<ConditionalWrapper
22+
condition={!!rating}
23+
wrapper={children => <div>{children}</div>}
24+
>
2125
<div className="flex sm items-center">
2226
<Avatar
2327
img={avatar}
@@ -38,7 +42,7 @@ const User = ({
3842
<Rating {...rest} score={rating} />
3943
</React.Fragment>
4044
)}
41-
</React.Fragment>
45+
</ConditionalWrapper>
4246
)
4347
}
4448

0 commit comments

Comments
 (0)