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

NotificationMarker docs page #1999

Merged
merged 27 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0723ccf
NotificationMarker docs starter
r100-stack Apr 15, 2024
7a1ffbb
Move styles to css file
r100-stack Apr 15, 2024
8978d37
Examples for statuses
r100-stack Apr 15, 2024
8ad834d
Example for pulsing
r100-stack Apr 15, 2024
45aacdb
Added links
r100-stack Apr 15, 2024
18b4e08
Remove unnecessary parts
r100-stack Apr 15, 2024
b18df24
nit
r100-stack Apr 15, 2024
a9cacdd
Merge branch 'main' into rohan/notification-marker-docs
r100-stack Apr 16, 2024
fc03683
Added labels to buttons
r100-stack Apr 16, 2024
5301a7f
Removed `propsPath` from frontmatter
r100-stack Apr 16, 2024
304aea7
Make note to sentence case
r100-stack Apr 17, 2024
237b7df
Show statuses as a list
r100-stack Apr 17, 2024
ce0b2ed
Added TODO for thumbnail
r100-stack Apr 17, 2024
ba9b4b9
Removed text examples
r100-stack Apr 17, 2024
55d01b1
Added usage
r100-stack Apr 17, 2024
370c478
Remove controlled section and merge it with usage
r100-stack Apr 17, 2024
3b6fff9
Reorder statuses examples
r100-stack Apr 17, 2024
5d85231
Removed custom CSS
r100-stack Apr 17, 2024
0c101d4
Update test images
r100-stack Apr 17, 2024
5fb64d7
Remove text from statuses example
r100-stack Apr 17, 2024
a8a2909
Add "Conditional rendering" section
r100-stack Apr 17, 2024
54e53d9
Apply suggestions
r100-stack Apr 17, 2024
accfa30
Merge branch 'main' into rohan/notification-marker-docs
r100-stack Apr 17, 2024
6be8fb6
Mention IconButton in usage
r100-stack Apr 17, 2024
8442075
Typos
r100-stack Apr 17, 2024
ea97678
Typo
r100-stack Apr 17, 2024
740ad25
Improved JSDocs for enabled
r100-stack Apr 17, 2024
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 14 additions & 19 deletions apps/react-workshop/src/NotificationMarker.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,16 @@ export const Basic = () => {
return (
<>
<NotificationMarker status='primary'>
<SvgNotification width={16} height={16} fill='currentColor' />
<SvgNotification fill='currentColor' />
</NotificationMarker>
<NotificationMarker status='primary'>Normal</NotificationMarker>
</>
);
};

export const WithButtons = () => {
return (
<>
<IconButton styleType='borderless'>
<IconButton label='Notifications' styleType='borderless'>
<NotificationMarker status='primary'>
<SvgNotification />
</NotificationMarker>
Expand All @@ -59,58 +58,54 @@ export const WithButtons = () => {
export const Pulsing = () => {
return (
<>
<IconButton styleType='borderless'>
<IconButton label='Notifications' styleType='borderless'>
<NotificationMarker status='negative' pulsing>
<SvgNotification />
</NotificationMarker>
</IconButton>

<NotificationMarker status='negative' pulsing>
<Text style={{ fontWeight: '700' }}>URGENT</Text>
</NotificationMarker>
</>
);
};

export const Status = () => {
return (
<>
<NotificationMarker status='primary'>Primary</NotificationMarker>
<IconButton styleType='borderless'>
<Text>Primary</Text>
mayank99 marked this conversation as resolved.
Show resolved Hide resolved
<IconButton label='Notifications' styleType='borderless'>
<NotificationMarker status='primary'>
<SvgNotification />
</NotificationMarker>
</IconButton>

<NotificationMarker status='positive'>Positive</NotificationMarker>
<IconButton styleType='borderless'>
<Text>Positive</Text>
<IconButton label='Notifications' styleType='borderless'>
<NotificationMarker status='positive'>
<SvgNotification />
</NotificationMarker>
</IconButton>

<NotificationMarker status='warning'>Warning</NotificationMarker>
<IconButton styleType='borderless'>
<Text>Warning</Text>
<IconButton label='Notifications' styleType='borderless'>
<NotificationMarker status='warning'>
<SvgNotification />
</NotificationMarker>
</IconButton>

<NotificationMarker status='negative'>Negative</NotificationMarker>
<IconButton styleType='borderless'>
<Text>Negative</Text>
<IconButton label='Notifications' styleType='borderless'>
<NotificationMarker status='negative'>
<SvgNotification />
</NotificationMarker>
</IconButton>

<NotificationMarker status='white'>White</NotificationMarker>
<Text>White</Text>
<div style={{ display: 'flex', columnGap: '10px' }}>
<IconButton styleType='high-visibility'>
<IconButton label='Notifications' styleType='high-visibility'>
<NotificationMarker status='white'>
<SvgNotification />
</NotificationMarker>
</IconButton>
<IconButton styleType='cta'>
<IconButton label='Notifications' styleType='cta'>
<NotificationMarker status='white'>
<SvgNotification />
</NotificationMarker>
Expand Down
2 changes: 1 addition & 1 deletion apps/website/src/content/docs/inputwithdecorations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Add icons, buttons and other various subcomponents to input.

### Status

InputWithDecorations can have positive, warning and negative status.
InputWithDecorations can have positive, warning, or negative statuses.

<LiveExample src='InputWithDecorations.status.jsx'>
<AllExamples.InputWithDecorationsStatusExample client:load />
Expand Down
65 changes: 65 additions & 0 deletions apps/website/src/content/docs/notificationmarker.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
title: NotificationMarker
description: Shows a notification marker dot at the top right of the component.
thumbnail: #TODO
---

<p>{frontmatter.description}</p>

<LiveExample src='NotificationMarker.main.jsx'>
<AllExamples.NotificationMarkerMainExample client:load />
</LiveExample>

## Usage

Wrap the content with the `NotificationMarker` component.

```jsx {2, 4}
<IconButton label='Notifications' styleType='borderless'>
mayank99 marked this conversation as resolved.
Show resolved Hide resolved
<NotificationMarker>
<SvgNotification />
</NotificationMarker>
</IconButton>
```

### Conditional rendering

There are many situations when the notification marker needs to appear/disappear depending on the application lifetime. Instead of conditionally rendering the `NotificationMarker` in such situations, the `enabled` prop can be used.

```jsx
<NotificationMarker enabled={notifications.length 0}>
</NotificationMarker>
```

When `enabled` is set to `false`, the DOM element will still be present, but the notification marker will not be displayed visually.

### Status
mayank99 marked this conversation as resolved.
Show resolved Hide resolved

`NotificationMarker`s can have the follow statuese:

- `primary` (default)
- `positive`
- `warning`
- `negative`
- `white`

<LiveExample src='NotificationMarker.statuses.jsx'>
<AllExamples.NotificationMarkerStatusesExample client:load />
</LiveExample>

The `white` status is used on colored backgrounds, such as when using it in the [high visibility](button#high-visibility) or the [call-to-action](button#call-to-action) buttons.

### Pulsing

To give a higher importantance to the notification, you can use the `pulsing` prop to show a pulse effect around the marker.

**Note**: This prop should be used sparingly as it can be distracting to the user.

<LiveExample src='NotificationMarker.pulsing.jsx'>
<AllExamples.NotificationMarkerPulsingExample client:load />
</LiveExample>

## Props

<PropsTable path={'@itwin/itwinui-react/esm/core/NotificationMarker/NotificationMarker.d.ts'} />
2 changes: 1 addition & 1 deletion apps/website/src/content/docs/searchbox.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: SearchBox
description: A search input component
propsPath: '@itwin/itwinui-react/esm/core/SearchBox/SearchBox.d.ts'
thumbnail:
thumbnail: #TODO
---

<p>{frontmatter.description}</p>
Expand Down
15 changes: 15 additions & 0 deletions examples/NotificationMarker.main.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import * as React from 'react';
import { NotificationMarker } from '@itwin/itwinui-react';
import { SvgNotification } from '@itwin/itwinui-icons-react';

export default () => {
return (
<NotificationMarker status='primary'>
<SvgNotification />
</NotificationMarker>
);
};
17 changes: 17 additions & 0 deletions examples/NotificationMarker.pulsing.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import * as React from 'react';
import { NotificationMarker, IconButton, Text } from '@itwin/itwinui-react';
import { SvgNotification } from '@itwin/itwinui-icons-react';

export default () => {
return (
<IconButton label='Notifications' styleType='borderless'>
<NotificationMarker status='negative' pulsing>
<SvgNotification />
</NotificationMarker>
</IconButton>
);
};
4 changes: 4 additions & 0 deletions examples/NotificationMarker.statuses.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.demo-container {
display: flex;
column-gap: 10px;
}
49 changes: 49 additions & 0 deletions examples/NotificationMarker.statuses.jsx
mayank99 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import * as React from 'react';
import { NotificationMarker, IconButton, Text } from '@itwin/itwinui-react';
import { SvgNotification } from '@itwin/itwinui-icons-react';

export default () => {
return (
<div className='demo-container'>
<IconButton label='Primary' styleType='borderless'>
<NotificationMarker status='primary'>
<SvgNotification />
</NotificationMarker>
</IconButton>

<IconButton label='Positive' styleType='borderless'>
<NotificationMarker status='positive'>
<SvgNotification />
</NotificationMarker>
</IconButton>

<IconButton label='Warning' styleType='borderless'>
<NotificationMarker status='warning'>
<SvgNotification />
</NotificationMarker>
</IconButton>

<IconButton label='Negative' styleType='borderless'>
<NotificationMarker status='negative'>
<SvgNotification />
</NotificationMarker>
</IconButton>

<IconButton label='White' styleType='high-visibility'>
<NotificationMarker status='white'>
<SvgNotification />
</NotificationMarker>
</IconButton>

<IconButton label='White' styleType='cta'>
<NotificationMarker status='white'>
<SvgNotification />
</NotificationMarker>
</IconButton>
</div>
);
};
20 changes: 20 additions & 0 deletions examples/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,26 @@ export { NonIdealStateErrorExample };

// ----------------------------------------------------------------------------

import { default as NotificationMarkerMainExampleRaw } from './NotificationMarker.main';
const NotificationMarkerMainExample = withThemeProvider(
NotificationMarkerMainExampleRaw,
);
export { NotificationMarkerMainExample };

import { default as NotificationMarkerStatusesExampleRaw } from './NotificationMarker.statuses';
const NotificationMarkerStatusesExample = withThemeProvider(
NotificationMarkerStatusesExampleRaw,
);
export { NotificationMarkerStatusesExample };

import { default as NotificationMarkerPulsingExampleRaw } from './NotificationMarker.pulsing';
const NotificationMarkerPulsingExample = withThemeProvider(
NotificationMarkerPulsingExampleRaw,
);
export { NotificationMarkerPulsingExample };

// ----------------------------------------------------------------------------

import { default as OverlayMainExampleRaw } from './Overlay.main';
const OverlayMainExample = withThemeProvider(OverlayMainExampleRaw);
export { OverlayMainExample };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ type NotificationMarkerProps = {
*/
pulsing?: boolean;
/**
* Set this programmatically to false when you just want to render the passed children without the notification
* You can use this prop to show or hide the notification marker but still keep it in the DOM (e.g. to prevent layout shifts).
* @default true
* @example
* let [newMessagesCount, ...] = useState(0);
* ...
* <NotificationMarker enabled={newMessagesCount > 0}>
* <NotificationMarker enabled={notifications.length > 0}>
* <SvgNotification />
* </NotificationMarker>
*/
Expand Down
Loading