feat: added svg fill color as well as clip and fill rules to session icon component

this lets us render more complex svgs like the recovery password icon
pull/3056/head
William Grant 1 year ago
parent c909969c6b
commit adb9166a11

@ -15,6 +15,9 @@ export type SessionIconProps = {
glowStartDelay?: number; glowStartDelay?: number;
noScale?: boolean; noScale?: boolean;
backgroundColor?: string; backgroundColor?: string;
fill?: string;
clipRule?: ClipRule;
fillRule?: FillRule;
dataTestId?: string; dataTestId?: string;
}; };
@ -42,6 +45,9 @@ const getIconDimensionFromIconSize = (iconSize: SessionIconSize | number) => {
} }
}; };
type ClipRule = 'nonzero' | 'evenodd' | 'inherit';
type FillRule = 'nonzero' | 'evenodd';
type StyledSvgProps = { type StyledSvgProps = {
width: string | number; width: string | number;
height: string | number; height: string | number;
@ -54,6 +60,9 @@ type StyledSvgProps = {
noScale?: boolean; noScale?: boolean;
iconColor?: string; iconColor?: string;
backgroundColor?: string; backgroundColor?: string;
fill?: string;
clipRule?: ClipRule;
filleRule?: FillRule;
}; };
const rotate = keyframes` const rotate = keyframes`
@ -132,22 +141,13 @@ const Svg = memo(styled.svg<StyledSvgProps>`
transition: inherit; transition: inherit;
`); `);
const SessionSvg = (props: { const SessionSvg = (
viewBox: string; props: StyledSvgProps & {
path: string | Array<string>; viewBox: string;
width: string | number; path: string | Array<string>;
height: string | number; dataTestId?: string;
iconRotation: number; }
iconColor?: string; ) => {
rotateDuration?: number;
glowDuration?: number;
glowStartDelay?: number;
noScale?: boolean;
borderRadius?: string;
backgroundColor?: string;
iconPadding?: string;
dataTestId?: string;
}) => {
const colorSvg = props.iconColor ? props.iconColor : '--button-icon-stroke-color'; const colorSvg = props.iconColor ? props.iconColor : '--button-icon-stroke-color';
const pathArray = props.path instanceof Array ? props.path : [props.path]; const pathArray = props.path instanceof Array ? props.path : [props.path];
const propsToPick = { const propsToPick = {
@ -163,6 +163,9 @@ const SessionSvg = (props: {
backgroundColor: props.backgroundColor, backgroundColor: props.backgroundColor,
borderRadius: props.borderRadius, borderRadius: props.borderRadius,
iconPadding: props.iconPadding, iconPadding: props.iconPadding,
fill: props.fill,
clipRule: props.clipRule,
fillRule: props.filleRule,
dataTestId: props.dataTestId, dataTestId: props.dataTestId,
}; };
@ -186,6 +189,9 @@ export const SessionIcon = (props: SessionIconProps) => {
noScale, noScale,
backgroundColor, backgroundColor,
iconPadding, iconPadding,
fill,
clipRule = 'nonzero',
fillRule = 'nonzero',
dataTestId, dataTestId,
} = props; } = props;
let { iconSize, iconRotation } = props; let { iconSize, iconRotation } = props;
@ -211,6 +217,9 @@ export const SessionIcon = (props: SessionIconProps) => {
iconColor={iconColor} iconColor={iconColor}
backgroundColor={backgroundColor} backgroundColor={backgroundColor}
iconPadding={iconPadding} iconPadding={iconPadding}
fill={fill}
clipRule={clipRule}
filleRule={fillRule}
dataTestId={dataTestId} dataTestId={dataTestId}
/> />
); );

Loading…
Cancel
Save