forked from wagtail/wagtail
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate avatar template to an include tag
Includes style guide & storybook implementation Fixes wagtail#8655
- Loading branch information
Showing
12 changed files
with
88 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{% load wagtailadmin_tags %} | ||
{% comment "text/markdown" %} | ||
Displays a user avatar using the avatar template | ||
Variables this template accepts: | ||
|
||
- `classname` - if present, adds classname to the root class list | ||
- `user` - A user object to use for the avatar image | ||
- `size` (string?) - small, large, square | ||
- `tooltip` (string?) - Modifier classes | ||
{% endcomment %} | ||
<span class='{% classnames "avatar" size classname %}' {% if tooltip %} data-wagtail-tooltip="{{ tooltip }}" {% endif %}> | ||
{% if size == 'small' %} | ||
<img src="{% avatar_url user size=25 %}" alt="" decoding="async" loading="lazy"/> | ||
{% elif size == 'large' %} | ||
<img src="{% avatar_url user size=100 %}" alt="" decoding="async" loading="lazy"/> | ||
{% elif size == 'square' %} | ||
<img src="{% avatar_url user %}" alt="" decoding="async" loading="lazy"/> | ||
{% else %} | ||
<img src="{% avatar_url user %}" alt="" decoding="async" loading="lazy"/> | ||
{% endif %} | ||
</span> |
40 changes: 40 additions & 0 deletions
40
wagtail/admin/templates/wagtailadmin/shared/avatar.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from 'react'; | ||
import { Pattern, generateDocs } from 'storybook-django/src/react'; | ||
|
||
import template from './avatar.html'; | ||
|
||
const { docs, argTypes } = generateDocs(template); | ||
|
||
export default { | ||
parameters: { | ||
docs, | ||
}, | ||
argTypes: { | ||
...argTypes, | ||
size: { | ||
options: [null, 'small', 'large', 'square'], | ||
}, | ||
}, | ||
}; | ||
|
||
const Template = (args) => <Pattern filename={__filename} context={args} />; | ||
|
||
export const Base = Template.bind({}); | ||
Base.args = { | ||
size: 'null', | ||
}; | ||
|
||
export const Small = Template.bind({}); | ||
Small.args = { | ||
size: 'small', | ||
}; | ||
|
||
export const Large = Template.bind({}); | ||
Large.args = { | ||
size: 'large', | ||
}; | ||
|
||
export const Square = Template.bind({}); | ||
Square.args = { | ||
size: 'square', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
{% load wagtailadmin_tags %} | ||
|
||
<span class="avatar small"> | ||
<img src="{% avatar_url user size=25 %}" alt="" decoding="async" loading="lazy"/> | ||
</span> | ||
{% avatar user=user size="small" %} | ||
|
||
{% if not username %}{{ user }}{% else %}{{ username }}{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters