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

chore(PPDSC-2358): removed loading state for Tag and Flag components #359

Merged
Show file tree
Hide file tree
Changes from 13 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
4 changes: 0 additions & 4 deletions site/pages/components/tag.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ Tags have a number of props to facilitate a variety of uses:
If true, the Tag will render the disabled state of the style preset. If an
href is also passed, the Tag will not open the provided href on click.
</Prop>
<Prop name="loading" type="boolean" default={false}>
If true, this will cause the Tag to render the loading state of the style
preset.
</Prop>
<Prop name="overrides" type="object">
If provided, overrides the respective presets for the component and provided
elements. Here are the overrides that the Tag accepts:
Expand Down
9 changes: 6 additions & 3 deletions src/button/styled.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import {Flag} from '../flag';
import {BaseFlag} from '../flag/flag';
import {logicalProps} from '../utils/logical-properties';
import {styled} from '../utils/style';
import {getTransitionPreset} from '../utils/style/transition-preset';
import {ButtonOrButtonLinkProps} from './types';

export const StyledFlag = styled(Flag)<Omit<ButtonOrButtonLinkProps, 'size'>>`
export const StyledFlag = styled(BaseFlag)<
Omit<ButtonOrButtonLinkProps, 'size'>
>`
margin: 0; //reset for safari

${({size}) => getTransitionPreset(`button.${size}`, '')};
${({size}) => getTransitionPreset(`button.${size}`, '')}
${({loading, disabled}) => {
mstuartf marked this conversation as resolved.
Show resolved Hide resolved
if (disabled) {
return null;
}
const cursor = loading ? 'progress' : 'pointer';
return {cursor};
}}

${({size}) =>
logicalProps(
`button.${size}`,
Expand Down
3 changes: 2 additions & 1 deletion src/flag/flag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import defaults from './defaults';
import stylePresets from './style-presets';
import {withOwnTheme} from '../utils/with-own-theme';

const BaseFlag = React.forwardRef<
export const BaseFlag = React.forwardRef<
HTMLDivElement,
BaseFlagProps<BaseFlagOverrides>
>(({children, overrides, loading, disabled, as, ...props}, ref) => {
Expand Down Expand Up @@ -59,6 +59,7 @@ const ThemelessFlag = React.forwardRef<HTMLDivElement, FlagProps>(
<BaseFlag
data-testid="flag"
{...props}
loading={false}
ref={ref}
overrides={{
...theme.componentDefaults.flag[size],
Expand Down
5 changes: 4 additions & 1 deletion src/flag/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@ export interface BaseFlagProps<TOverrides> {
as?: keyof JSX.IntrinsicElements;
}
export interface FlagProps
extends BaseFlagProps<Omit<BaseFlagOverrides, 'transitionPreset'>> {}
extends Omit<
BaseFlagProps<Omit<BaseFlagOverrides, 'transitionPreset'>>,
'loading'
> {}
4 changes: 2 additions & 2 deletions src/tag/tag.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import {TagProps} from './types';
import {Flag} from '../flag';
import {BaseFlag} from '../flag/flag';
import {filterOutFalsyProperties} from '../utils/filter-object';
import {as as emotionAs} from '../utils/component';
import {useTheme} from '../theme';
Expand All @@ -10,7 +10,7 @@ import stylePresets from './style-presets';
import {withOwnTheme} from '../utils/with-own-theme';
import {getTransitionPreset} from '../utils/style/transition-preset';

const StyledFlag = styled(Flag)`
const StyledFlag = styled(BaseFlag)`
${({href, disabled}: TagProps) => href && !disabled && {cursor: 'pointer'}}
${({size}) => getTransitionPreset(`tag.${size}`, '')};
`;
Expand Down
2 changes: 1 addition & 1 deletion src/tag/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import React from 'react';
import {BaseFlagOverrides, BaseFlagProps} from '../flag';

export interface TagProps
extends BaseFlagProps<BaseFlagOverrides>,
extends Omit<BaseFlagProps<BaseFlagOverrides>, 'loading'>,
React.AnchorHTMLAttributes<HTMLAnchorElement> {}