Skip to content

Commit d2561d7

Browse files
author
Luke Bowerman
authored
Fix avatar presentation (#1610)
* Adding stories * Update naming and image ref * Image snapshots
1 parent 718101a commit d2561d7

File tree

11 files changed

+37
-58
lines changed

11 files changed

+37
-58
lines changed

packages/components/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.9.22]
9+
10+
### Fixed
11+
12+
- `AvatarIcon`, `AvatarUser`, `AvatarCombo` - corrected rendering flaw where initials or icon weren't centered
13+
814
## [0.9.21]
915

1016
### Changed
4.38 KB
Loading
1.79 KB
Loading
1.48 KB
Loading
4.26 KB
Loading

packages/components/src/Avatar/Avatar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export const avatarCSS = css`
119119
120120
align-items: center;
121121
border-radius: 100%;
122-
display: flex;
122+
display: grid;
123123
justify-items: center;
124124
overflow: hidden;
125125

storybook/src/AvatarCombo.stories.tsx renamed to packages/components/src/Avatar/AvatarCombo.story.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,17 @@
2525
*/
2626

2727
import React from 'react'
28-
import { AvatarCombo, AvatarComboProps } from '@looker/components'
2928
import { Story } from '@storybook/react/types-6-0'
29+
import { AvatarCombo, AvatarComboProps } from './AvatarCombo'
3030

3131
const Template: Story<AvatarComboProps> = (args) => <AvatarCombo {...args} />
3232

3333
/* eslint-disable @typescript-eslint/camelcase */
3434
const user = {
35-
avatar_url: 'https://www.fillmurray.com/150/150',
36-
first_name: 'Bill',
37-
last_name: 'Murray',
35+
avatar_url:
36+
'https://github.com/looker-open-source/components/blob/1b708b472d974987e80c30bbbb286911a438542a/packages/components/test-assets/cheese.png?raw=true',
37+
first_name: 'Cheddar',
38+
last_name: 'Cheese',
3839
}
3940
/* eslint-enable @typescript-eslint/camelcase */
4041

@@ -47,5 +48,5 @@ Primary.args = {
4748

4849
export default {
4950
component: AvatarCombo,
50-
title: 'Avatar/AvatarCombo',
51+
title: 'AvatarCombo',
5152
}

storybook/src/AvatarIcon.stories.tsx renamed to packages/components/src/Avatar/AvatarIcon.story.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
*/
2626

2727
import React from 'react'
28-
import { AvatarIcon, AvatarIconProps } from '@looker/components'
2928
import { Story } from '@storybook/react/types-6-0'
29+
import { AvatarIconProps, AvatarIcon } from './AvatarIcon'
3030

3131
const Template: Story<AvatarIconProps> = (args) => <AvatarIcon {...args} />
3232

@@ -38,5 +38,5 @@ Primary.args = {
3838

3939
export default {
4040
component: AvatarIcon,
41-
title: 'Avatar/AvatarIcon',
41+
title: 'AvatarIcon',
4242
}

storybook/src/AvatarUser.stories.tsx renamed to packages/components/src/Avatar/AvatarUser.story.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,30 @@
2525
*/
2626

2727
import React from 'react'
28-
import { AvatarUser, AvatarUserProps } from '@looker/components'
2928
import { Story } from '@storybook/react/types-6-0'
29+
import { AvatarUserProps, AvatarUser } from './AvatarUser'
3030

3131
const Template: Story<AvatarUserProps> = (args) => <AvatarUser {...args} />
3232

3333
/* eslint-disable @typescript-eslint/camelcase */
3434
const user = {
35-
avatar_url: 'https://www.fillmurray.com/150/150',
36-
first_name: 'Bill',
37-
last_name: 'Murray',
35+
avatar_url:
36+
'https://github.com/looker-open-source/components/blob/1b708b472d974987e80c30bbbb286911a438542a/packages/components/test-assets/cheese.png?raw=true',
37+
first_name: 'Cheddar',
38+
last_name: 'Cheese',
3839
}
39-
/* eslint-enable @typescript-eslint/camelcase */
4040

4141
export const Primary = Template.bind({})
4242
Primary.args = {
4343
user,
4444
}
4545

46+
export const Initials = Template.bind({})
47+
Initials.args = {
48+
user: { ...user, avatar_url: null },
49+
}
50+
4651
export default {
4752
component: AvatarUser,
48-
title: 'Avatar/AvatarUser',
53+
title: 'AvatarUser',
4954
}

packages/components/src/Avatar/__snapshots__/Avatar.test.tsx.snap

Lines changed: 11 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ exports[`Avatar AvatarCombo renders Avatar and its secondary avatar 1`] = `
5252
-ms-flex-align: center;
5353
align-items: center;
5454
border-radius: 100%;
55-
display: -webkit-box;
56-
display: -webkit-flex;
57-
display: -ms-flexbox;
58-
display: flex;
55+
display: grid;
5956
justify-items: center;
6057
overflow: hidden;
6158
background: currentColor;
@@ -81,10 +78,7 @@ exports[`Avatar AvatarCombo renders Avatar and its secondary avatar 1`] = `
8178
-ms-flex-align: center;
8279
align-items: center;
8380
border-radius: 100%;
84-
display: -webkit-box;
85-
display: -webkit-flex;
86-
display: -ms-flexbox;
87-
display: flex;
81+
display: grid;
8882
justify-items: center;
8983
overflow: hidden;
9084
border: solid 1px currentColor;
@@ -219,10 +213,7 @@ exports[`Avatar AvatarCombo renders Avatar initials and secondary with Code icon
219213
-ms-flex-align: center;
220214
align-items: center;
221215
border-radius: 100%;
222-
display: -webkit-box;
223-
display: -webkit-flex;
224-
display: -ms-flexbox;
225-
display: flex;
216+
display: grid;
226217
justify-items: center;
227218
overflow: hidden;
228219
background: currentColor;
@@ -248,10 +239,7 @@ exports[`Avatar AvatarCombo renders Avatar initials and secondary with Code icon
248239
-ms-flex-align: center;
249240
align-items: center;
250241
border-radius: 100%;
251-
display: -webkit-box;
252-
display: -webkit-flex;
253-
display: -ms-flexbox;
254-
display: flex;
242+
display: grid;
255243
justify-items: center;
256244
overflow: hidden;
257245
border: solid 1px currentColor;
@@ -373,10 +361,7 @@ exports[`Avatar AvatarCombo renders AvatarIcon and secondary avatar if user is n
373361
-ms-flex-align: center;
374362
align-items: center;
375363
border-radius: 100%;
376-
display: -webkit-box;
377-
display: -webkit-flex;
378-
display: -ms-flexbox;
379-
display: flex;
364+
display: grid;
380365
justify-items: center;
381366
overflow: hidden;
382367
border: solid 1px currentColor;
@@ -406,10 +391,7 @@ exports[`Avatar AvatarCombo renders AvatarIcon and secondary avatar if user is n
406391
-ms-flex-align: center;
407392
align-items: center;
408393
border-radius: 100%;
409-
display: -webkit-box;
410-
display: -webkit-flex;
411-
display: -ms-flexbox;
412-
display: flex;
394+
display: grid;
413395
justify-items: center;
414396
overflow: hidden;
415397
border: solid 1px currentColor;
@@ -539,10 +521,7 @@ exports[`Avatar AvatarIcon renders 1`] = `
539521
-ms-flex-align: center;
540522
align-items: center;
541523
border-radius: 100%;
542-
display: -webkit-box;
543-
display: -webkit-flex;
544-
display: -ms-flexbox;
545-
display: flex;
524+
display: grid;
546525
justify-items: center;
547526
overflow: hidden;
548527
border: solid 1px currentColor;
@@ -633,10 +612,7 @@ exports[`Avatar AvatarIcon renders different icon if specified 1`] = `
633612
-ms-flex-align: center;
634613
align-items: center;
635614
border-radius: 100%;
636-
display: -webkit-box;
637-
display: -webkit-flex;
638-
display: -ms-flexbox;
639-
display: flex;
615+
display: grid;
640616
justify-items: center;
641617
overflow: hidden;
642618
border: solid 1px currentColor;
@@ -717,10 +693,7 @@ exports[`Avatar AvatarUser shows initials if has broken url as avatar_url 1`] =
717693
-ms-flex-align: center;
718694
align-items: center;
719695
border-radius: 100%;
720-
display: -webkit-box;
721-
display: -webkit-flex;
722-
display: -ms-flexbox;
723-
display: flex;
696+
display: grid;
724697
justify-items: center;
725698
overflow: hidden;
726699
background: currentColor;
@@ -771,10 +744,7 @@ exports[`Avatar AvatarUser shows initials if it has null as avatar_url 1`] = `
771744
-ms-flex-align: center;
772745
align-items: center;
773746
border-radius: 100%;
774-
display: -webkit-box;
775-
display: -webkit-flex;
776-
display: -ms-flexbox;
777-
display: flex;
747+
display: grid;
778748
justify-items: center;
779749
overflow: hidden;
780750
background: currentColor;
@@ -828,10 +798,7 @@ exports[`Avatar AvatarUser shows user profile picture if it has good avatar_url
828798
-ms-flex-align: center;
829799
align-items: center;
830800
border-radius: 100%;
831-
display: -webkit-box;
832-
display: -webkit-flex;
833-
display: -ms-flexbox;
834-
display: flex;
801+
display: grid;
835802
justify-items: center;
836803
overflow: hidden;
837804
background: currentColor;

0 commit comments

Comments
 (0)