Skip to content
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

[PLAY-111] Size Prop styling needs to be corrected: Avatar #1758

Merged
merged 3 commits into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion playbook/app/pb_kits/playbook/pb_avatar/_avatar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const Avatar = (props: AvatarProps) => {
const dataProps = buildDataProps(data)
const ariaProps = buildAriaProps(aria)
const classes = classnames(
buildCss('pb_avatar_kit', size),
buildCss('pb_avatar_kit', `size_${size}`),
globalProps(props),
className
)
Expand Down
4 changes: 2 additions & 2 deletions playbook/app/pb_kits/playbook/pb_avatar/_avatar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ $avatar-sizes: (
position: relative;

@each $name, $size in $avatar-sizes {
&[class*=_#{$name}],
&[class*=_#{$name}_thumb] {
&[class*=_size_#{$name}],
&[class*=_size_#{$name}_thumb] {
width: $size;
height: $size;
object-fit: cover;
Expand Down
2 changes: 1 addition & 1 deletion playbook/app/pb_kits/playbook/pb_avatar/avatar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def initials
end

def classname
generate_classname("pb_avatar_kit", size)
generate_classname("pb_avatar_kit", "size_#{size}")
end

def online_status_props
Expand Down
2 changes: 1 addition & 1 deletion playbook/app/pb_kits/playbook/pb_avatar/avatar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ test('loads the given image url and name', () => {
const image = screen.getByAltText(imageAlt)
const initials = name.split(/\s/)[0].substr(0, 1) + name.split(/\s/)[1].substr(0, 1)

expect(kit).toHaveClass('pb_avatar_kit_md')
expect(kit).toHaveClass('pb_avatar_kit_size_md')
expect(kit).toHaveAttribute('data-initials', initials)
expect(image).toHaveAttribute('data-src', imageUrl)
expect(image).toHaveAttribute('src', imageUrl)
Expand Down
6 changes: 3 additions & 3 deletions playbook/spec/pb_kits/playbook/kits/avatar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
}
describe "#classname" do
it "returns namespaced class name", :aggregate_failures do
expect(subject.new({}).classname).to eq "pb_avatar_kit_md"
expect(subject.new(classname: "additional_class").classname).to eq "pb_avatar_kit_md additional_class"
expect(subject.new(size: "lg").classname).to eq "pb_avatar_kit_lg"
expect(subject.new({}).classname).to eq "pb_avatar_kit_size_md"
expect(subject.new(classname: "additional_class").classname).to eq "pb_avatar_kit_size_md additional_class"
expect(subject.new(size: "lg").classname).to eq "pb_avatar_kit_size_lg"
end
end
end