-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add dynamic params to
AvatarComponent
- Loading branch information
Showing
9 changed files
with
79 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,81 @@ | ||
class AvatarComponentPreview < ViewComponent::Preview | ||
def default | ||
# Avatar Component | ||
# ------------ | ||
# Avatars are used to show a thumbnail representation of an individual or business in the interface. | ||
# | ||
# @param customer toggle "Whether the avatar is for a customer" | ||
# @param name text "The name of the person" | ||
# @param size select "Size of avatar" {{Polaris::AvatarComponent::SIZE_MAPPINGS.keys}} | ||
# @param shape select "Shape of avatar" {{Polaris::AvatarComponent::SHAPE_MAPPINGS.keys}} | ||
# @param source url "URL of the avatar image which falls back to default if blank" | ||
# @param initials text "Initials of person to display" | ||
def default( | ||
customer: true, | ||
name: "Farrah", | ||
size: :medium, | ||
shape: :round, | ||
source: "https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-180x180.png", | ||
initials: "AK" | ||
) | ||
render_with_template( | ||
locals: { | ||
customer: customer, | ||
name: name, | ||
size: size, | ||
shape: shape, | ||
source: source, | ||
initials: initials | ||
} | ||
) | ||
end | ||
|
||
def extra_small | ||
|
||
# @param customer toggle "Whether the avatar is for a customer" | ||
# @param name text "The name of the person" | ||
# @param size select "Size of avatar" {{Polaris::AvatarComponent::SIZE_MAPPINGS.keys}} | ||
def basic(customer: true, name: "Farrah", size: :medium) | ||
render_with_template( | ||
locals: { | ||
customer: customer, | ||
name: name, | ||
size: size | ||
} | ||
) | ||
end | ||
|
||
# @param size select "Size of avatar" {{Polaris::AvatarComponent::SIZE_MAPPINGS.keys}} | ||
def extra_small(size: :extra_small) | ||
render_with_template( | ||
locals: { | ||
size: size | ||
} | ||
) | ||
end | ||
|
||
def square | ||
# @param shape select "Shape of avatar" {{Polaris::AvatarComponent::SHAPE_MAPPINGS.keys}} | ||
def square(shape: :square) | ||
render_with_template( | ||
locals: { | ||
shape: shape | ||
} | ||
) | ||
end | ||
|
||
def initials | ||
# @param initials text "Initials of person to display" | ||
def initials(initials: "AK") | ||
render_with_template( | ||
locals: { | ||
initials: initials | ||
} | ||
) | ||
end | ||
|
||
def image | ||
# @param source url "URL of the avatar image which falls back to default if blank" | ||
def image(source: "https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-180x180.png") | ||
render_with_template( | ||
locals: { | ||
source: source | ||
} | ||
) | ||
end | ||
end |
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 @@ | ||
<%= polaris_avatar(customer: customer, name: name, size: size) %> |
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 +1 @@ | ||
<%= polaris_avatar(customer: true, name: "Farrah") %> | ||
<%= polaris_avatar(customer: customer, name: name, size: size, shape: shape, source: source, initials: initials) %> |
2 changes: 1 addition & 1 deletion
2
demo/app/previews/avatar_component_preview/extra_small.html.erb
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 +1 @@ | ||
<%= polaris_avatar(customer: true, size: :extra_small, name: "Farrah") %> | ||
<%= polaris_avatar(size: size) %> |
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,3 +1 @@ | ||
<%= polaris_avatar( | ||
source: "https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-180x180.png", | ||
) %> | ||
<%= polaris_avatar(source: source) %> |
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 +1 @@ | ||
<%= polaris_avatar(initials: "KP", size: :small) %> | ||
<%= polaris_avatar(initials: initials) %> |
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 +1 @@ | ||
<%= polaris_avatar(name: "Shop One", shape: :square) %> | ||
<%= polaris_avatar(shape: shape) %> |