Skip to content

Commit

Permalink
refactor(website, sync feedback): update demo layout
Browse files Browse the repository at this point in the history
docs(react, sync feedback): add JsDoc comments
  • Loading branch information
GermainBergeron committed Mar 22, 2022
1 parent 5475fc1 commit ccf5c00
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 44 deletions.
11 changes: 10 additions & 1 deletion packages/react/src/components/syncFeedback/SyncFeedback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@ import * as React from 'react';
import {Svg} from '../svg/Svg';

export interface ISyncFeedbackProps {
/**
* The label of the current state
*
* @default 'Saving changes...' for 'SYNCING', 'Changes saved' for 'SUCCESS', and 'Changes could not be saved.' for 'ERROR'.
*/
feedback?: string;
/**
* The current state of the sync feedback component
* Either 'SYNCING', 'SUCCESS', 'ERROR' or 'NONE'
*/
state: string;
}

Expand All @@ -17,7 +26,7 @@ export const DEFAULT_SYNC_FEEDBACK_SYNCING_LABEL: string = 'Saving changes...';
export const DEFAULT_SYNC_FEEDBACK_SUCCESS_LABEL: string = 'Changes saved';
export const DEFAULT_SYNC_FEEDBACK_ERROR_LABEL: string = 'Changes could not be saved.';

export class SyncFeedback extends React.Component<ISyncFeedbackProps, any> {
export class SyncFeedback extends React.PureComponent<ISyncFeedbackProps> {
render() {
const classes = ['sync-feedback'];
if (this.props.state === SyncFeedbackState.ERROR) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {SyncFeedback, SyncFeedbackState} from '@coveord/plasma-react';
import * as React from 'react';

export default () => (
<table className="table">
<tr>
<td>NONE</td>
<td>
<SyncFeedback state={SyncFeedbackState.NONE} />
</td>
</tr>
<tr>
<td>SYNCING</td>
<td>
<SyncFeedback state={SyncFeedbackState.SYNCING} />
</td>
</tr>

<tr>
<td>SUCCESS</td>
<td>
<SyncFeedback state={SyncFeedbackState.SUCCESS} />
</td>
</tr>

<tr>
<td>ERROR</td>
<td>
<SyncFeedback state={SyncFeedbackState.ERROR} />
</td>
</tr>
</table>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {SyncFeedback, SyncFeedbackState} from '@coveord/plasma-react';
import * as React from 'react';

export default () => (
<>
<SyncFeedback state={SyncFeedbackState.SYNCING} feedback="There is something happening" />
<SyncFeedback state={SyncFeedbackState.SUCCESS} feedback="There was a success" />
<SyncFeedback state={SyncFeedbackState.ERROR} feedback="There was an error" />
</>
);
57 changes: 14 additions & 43 deletions packages/website/src/pages/feedback/SyncFeedback.tsx
Original file line number Diff line number Diff line change
@@ -1,45 +1,16 @@
import code from '@examples/SyncFeedback/SyncFeedback.example.tsx';
import label from '@examples/SyncFeedback/SyncFeedbackLabel.example.tsx';
import * as React from 'react';
import {SyncFeedback, SyncFeedbackState} from '@coveord/plasma-react';
import {PageLayout} from '../../building-blocs/PageLayout';

import PlasmaComponent from '../../building-blocs/PlasmaComponent';

// start-print
export class SyncFeedbackExample extends React.Component<any, any> {
render() {
return (
<PlasmaComponent id="SyncFeedback" title="Sync Feedback" withSource>
<div className="mt2">
<label className="form-control-label">SyncFeedback</label>
<div className="form-control">
<div className="mb2">
A SyncFeedback component on state NONE is invisible.
<SyncFeedback state={SyncFeedbackState.NONE} />
</div>
<div className="mb2">
There is a default feedback message for each state
<SyncFeedback state={SyncFeedbackState.SYNCING} />
<SyncFeedback state={SyncFeedbackState.SUCCESS} />
<SyncFeedback state={SyncFeedbackState.ERROR} />
</div>
<div className="mb2">
You can pass a custom feedback message
<SyncFeedback
state={SyncFeedbackState.SYNCING}
feedback="This message is a SyncFeedback component on state SYNCING"
/>
<SyncFeedback
state={SyncFeedbackState.SUCCESS}
feedback="This message is a SyncFeedback component on state SUCCESS"
/>
<SyncFeedback
state={SyncFeedbackState.ERROR}
feedback="This message is a SyncFeedback component on state ERROR"
/>
</div>
</div>
</div>
</PlasmaComponent>
);
}
}
export default SyncFeedbackExample;
export default () => (
<PageLayout
id="SyncFeedback"
title="Sync Feedback"
section="Feedback"
description="A sync feedback indicates the status of an operation to the user."
componentSourcePath="/numericInput/NumericInputConnected.tsx"
code={code}
examples={{label: {code: label, title: 'Custom Labels'}}}
/>
);

0 comments on commit ccf5c00

Please sign in to comment.