Skip to content

Commit

Permalink
Revert "[Docs] Update StatusBadge" (#10613)
Browse files Browse the repository at this point in the history
Reverts #10562.
Related to #10457.
  • Loading branch information
laurkim committed Sep 21, 2023
1 parent 5043e97 commit b037ca7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 54 deletions.
Original file line number Diff line number Diff line change
@@ -1,37 +1,24 @@
.StatusBadge {
font-size: var(--p-font-size-75);
font-size: var(--font-size-100);
letter-spacing: 0;
font-weight: var(--p-font-weight-medium);
padding: var(--p-space-05) var(--p-space-2);
color: var(--p-color-text-subdued);
border-radius: var(--p-border-radius-2);
}
font-weight: var(--font-weight-400);
border-radius: var(--border-radius-round);
padding: 0.05rem 0.25rem;
color: var(--text);

.toneSuccess {
background-color: var(--p-color-bg-success);
color: var(--p-color-text-success);
}
&[data-value='alpha'] {
background: var(--surface-attention);
}

.toneInfo {
background-color: var(--p-color-bg-info);
color: var(--p-color-text-info);
}

.toneAttention {
background-color: var(--p-color-bg-caution);
color: var(--p-color-text-caution);
}

.toneWarning {
background-color: var(--p-color-bg-warning);
color: var(--p-color-text-warning-experimental);
}

.toneCritical {
background-color: var(--p-color-bg-critical);
color: var(--p-color-text-critical);
}
&[data-value='warning'],
&[data-value='deprecated'],
&[data-value='legacy'] {
background: var(--surface-warning);
}

.toneNew {
background-color: var(--p-color-bg-transparent-subdued-experimental);
&[data-value='beta'],
&[data-value='information'],
&[data-value='new'] {
background: var(--surface-information);
}
}
23 changes: 4 additions & 19 deletions polaris.shopify.com/src/components/StatusBadge/StatusBadge.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,15 @@
import {Status} from '../../types';
import {className as classNames, variationName} from '../../utils/various';
import styles from './StatusBadge.module.scss';

interface Props {
status: Status;
}

type Tone = 'info' | 'success' | 'warning' | 'critical' | 'attention' | 'new';

const StatusToneMapping: {[S in Status]: Tone} = {
Alpha: 'info',
Beta: 'success',
Deprecated: 'critical',
Information: 'info',
Legacy: 'warning',
New: 'new',
Warning: 'warning',
};

function StatusBadge({status}: Props) {
const className = classNames(
styles.StatusBadge,
styles[variationName('tone', StatusToneMapping[status])],
return (
<div className={styles.StatusBadge} data-value={status.toLowerCase()}>
{status}
</div>
);

return <div className={className}>{status}</div>;
}

export default StatusBadge;
4 changes: 0 additions & 4 deletions polaris.shopify.com/src/utils/various.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ export const className = (...classNames: ClassName[]): string => {
.join(' ');
};

export const variationName = (name: string, value: string) => {
return `${name}${value.charAt(0).toUpperCase()}${value.slice(1)}`;
};

export const toPascalCase = (str: string): string =>
(str.match(/[a-zA-Z0-9]+/g) || [])
.map((w) => `${w.charAt(0).toUpperCase()}${w.slice(1)}`)
Expand Down

0 comments on commit b037ca7

Please sign in to comment.