Skip to content

Commit

Permalink
Design review
Browse files Browse the repository at this point in the history
- Better usage example in storybook
- Added missing `color=“plain”`
- Added iconType={`logo${rest.name}`} to attempt to create the logo
  • Loading branch information
cchaos committed Mar 23, 2022
1 parent b65b050 commit 710e3a0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { KibanaSolutionAvatar, KibanaSolutionAvatarProps } from './solution_avat

export default {
title: 'Solution Avatar',
description: 'A wrapper around EuiAvatar, with some extra styling',
description: 'A wrapper around EuiAvatar, specifically to stylize Elastic Solutions',
};

type Params = Pick<KibanaSolutionAvatarProps, 'size' | 'name'>;
Expand All @@ -23,10 +23,11 @@ export const PureComponent = (params: Params) => {
PureComponent.argTypes = {
name: {
control: 'text',
defaultValue: 'Solution Name',
defaultValue: 'Kibana',
},
size: {
control: 'radio',
options: ['s', 'm', 'l', 'xl', 'xxl'],
defaultValue: 'xxl',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import './solution_avatar.scss';

import React from 'react';
import classNames from 'classnames';

import { DistributiveOmit, EuiAvatar, EuiAvatarProps } from '@elastic/eui';
import classNames from 'classnames';

export type KibanaSolutionAvatarProps = DistributiveOmit<EuiAvatarProps, 'size'> & {
/**
Expand All @@ -20,11 +20,12 @@ export type KibanaSolutionAvatarProps = DistributiveOmit<EuiAvatarProps, 'size'>
};

/**
* Applies extra styling to a typical EuiAvatar
* Applies extra styling to a typical EuiAvatar;
* The `name` value will be appended to 'logo' to configure the `iconType` unless `iconType` is provided.
*/
export const KibanaSolutionAvatar = ({ className, size, ...rest }: KibanaSolutionAvatarProps) => {
return (
// @ts-ignore
// @ts-ignore Complains about ExclusiveUnion between `iconSize` and `iconType`, but works fine
<EuiAvatar
className={classNames(
'kbnSolutionAvatar',
Expand All @@ -33,8 +34,10 @@ export const KibanaSolutionAvatar = ({ className, size, ...rest }: KibanaSolutio
},
className
)}
color="plain"
size={size === 'xxl' ? 'xl' : size}
iconSize={size}
iconType={`logo${rest.name}`}
{...rest}
/>
);
Expand Down

0 comments on commit 710e3a0

Please sign in to comment.