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

feat(apps): add status chips #872

Merged
merged 3 commits into from
May 24, 2024
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"Kim Lan Phan Hoang",
"Abdallah Al Chami",
"Alexandre Chau",
"Basile Spaenlehauer"
"Basile Spaenlehauer",
"Jérémy La Scala"
],
"license": "AGPL-3.0-only",
"repository": "graasp/graasp-ui",
Expand Down
4 changes: 4 additions & 0 deletions src/appComponents/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ export { default as ErrorFallback } from './ErrorFallback';

export { default as QuestionLabel } from './QuestionLabel';

export { default as RequiredChip } from './statusChips/RequiredChip';
export { default as SubmittedChip } from './statusChips/SubmittedChip';
export { default as SavedChip } from './statusChips/SavedChip';

export type { UserFeedback } from './types';
20 changes: 20 additions & 0 deletions src/appComponents/statusChips/RequiredChip.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { Meta, StoryObj } from '@storybook/react';

import RequiredChip from './RequiredChip';

const meta: Meta<typeof RequiredChip> = {
title: 'Apps/Status chips/RequiredChip',
component: RequiredChip,
};

export default meta;

type Story = StoryObj<typeof RequiredChip>;

export const DefaultRequiredChip: Story = {
args: {
label: 'Required',
tooltip: 'This question is required',
dataCy: 'required-chip',
},
};
23 changes: 23 additions & 0 deletions src/appComponents/statusChips/RequiredChip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import WarningIcon from '@mui/icons-material/WarningRounded';
import Chip from '@mui/material/Chip';
import Tooltip from '@mui/material/Tooltip';

import { StatusChipProps } from './types';

const RequiredChip = ({
label,
tooltip,
dataCy,
}: StatusChipProps): JSX.Element => (
<Tooltip title={tooltip}>
<Chip
color='warning'
icon={<WarningIcon />}
label={label}
variant='outlined'
data-cy={dataCy}
/>
</Tooltip>
);

export default RequiredChip;
20 changes: 20 additions & 0 deletions src/appComponents/statusChips/SavedChip.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { Meta, StoryObj } from '@storybook/react';

import SavedChip from './SavedChip';

const meta: Meta<typeof SavedChip> = {
title: 'Apps/Status chips/SavedChip',
component: SavedChip,
};

export default meta;

type Story = StoryObj<typeof SavedChip>;

export const DefaultSavedChip: Story = {
args: {
label: 'Saved',
tooltip: 'Your answer has been saved.',
dataCy: 'saved-chip',
},
};
22 changes: 22 additions & 0 deletions src/appComponents/statusChips/SavedChip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import BackupIcon from '@mui/icons-material/Backup';
import Chip from '@mui/material/Chip';
import Tooltip from '@mui/material/Tooltip';

import { StatusChipProps } from './types';

const SavedChip = ({
label,
tooltip,
dataCy,
}: StatusChipProps): JSX.Element => (
<Tooltip title={tooltip}>
<Chip
icon={<BackupIcon />}
label={label}
variant='outlined'
data-cy={dataCy}
/>
</Tooltip>
);

export default SavedChip;
20 changes: 20 additions & 0 deletions src/appComponents/statusChips/SubmittedChip.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { Meta, StoryObj } from '@storybook/react';

import SubmittedChip from './SubmittedChip';

const meta: Meta<typeof SubmittedChip> = {
title: 'Apps/Status chips/SubmittedChip',
component: SubmittedChip,
};

export default meta;

type Story = StoryObj<typeof SubmittedChip>;

export const DefaultSubmittedChip: Story = {
args: {
label: 'Submitted',
tooltip: 'Your answer has been submitted.',
dataCy: 'submitted-chip',
},
};
23 changes: 23 additions & 0 deletions src/appComponents/statusChips/SubmittedChip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import CheckCircleOutlineIcon from '@mui/icons-material/CheckCircleOutline';
import Chip from '@mui/material/Chip';
import Tooltip from '@mui/material/Tooltip';

import { StatusChipProps } from './types';

const SubmittedChip = ({
label,
tooltip,
dataCy,
}: StatusChipProps): JSX.Element => (
<Tooltip title={tooltip}>
<Chip
color='info'
icon={<CheckCircleOutlineIcon />}
label={label}
variant='outlined'
data-cy={dataCy}
/>
</Tooltip>
);

export default SubmittedChip;
5 changes: 5 additions & 0 deletions src/appComponents/statusChips/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface StatusChipProps {
label: string;
tooltip: string;
dataCy: string;
}
8 changes: 7 additions & 1 deletion src/apps.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
export { ErrorFallback, QuestionLabel } from './appComponents';
export {
ErrorFallback,
QuestionLabel,
SavedChip,
SubmittedChip,
RequiredChip,
} from './appComponents';

export type { UserFeedback } from './appComponents';