From cf5593b6832c7eed1b705260bb8351d39236340a Mon Sep 17 00:00:00 2001 From: JF-Cozy Date: Mon, 25 Jul 2022 11:36:03 +0200 Subject: [PATCH] feat(Alert): Add new Alert and AlertTitle components --- docs/styleguide.config.js | 2 + react/Alert/Readme.md | 132 ++++ react/Alert/index.jsx | 113 ++++ react/AlertTitle/Readme.md | 1 + react/AlertTitle/index.jsx | 3 + react/MuiCozyTheme/makeOverrides.js | 110 +++- react/__snapshots__/examples.spec.jsx.snap | 704 ++++++++++++--------- react/examples.spec.jsx | 1 + react/index.js | 2 + 9 files changed, 765 insertions(+), 303 deletions(-) create mode 100644 react/Alert/Readme.md create mode 100644 react/Alert/index.jsx create mode 100644 react/AlertTitle/Readme.md create mode 100644 react/AlertTitle/index.jsx diff --git a/docs/styleguide.config.js b/docs/styleguide.config.js index 2875aedd2f..26cea62b13 100644 --- a/docs/styleguide.config.js +++ b/docs/styleguide.config.js @@ -136,6 +136,8 @@ module.exports = { { name: 'Special', components: () => [ + '../react/Alert/index.jsx', + '../react/AlertTitle/index.jsx', '../react/Alerter/index.jsx', '../react/AppIcon/index.jsx', '../react/AppTile/index.jsx', diff --git a/react/Alert/Readme.md b/react/Alert/Readme.md new file mode 100644 index 0000000000..9dcf642f53 --- /dev/null +++ b/react/Alert/Readme.md @@ -0,0 +1,132 @@ +```jsx +import Alert from 'cozy-ui/transpiled/react/Alert' +import AlertTitle from 'cozy-ui/transpiled/react/AlertTitle' +import Button from 'cozy-ui/transpiled/react/Buttons' +import Icon from 'cozy-ui/transpiled/react/Icon' +import Variants from 'cozy-ui/docs/components/Variants' +import DeviceLaptopIcon from 'cozy-ui/transpiled/react/Icons/DeviceLaptop' +import DownloadIcon from 'cozy-ui/transpiled/react/Icons/Download' + +const initialVariants = [{ + longText: false, + title: false, + block: false, + color: false, + largeIcon: false, + noIcon: false, + square: false, + actionOne: false, + actionTwo: false, + close: false +}] + +; + + + {variant => ( + : undefined} + action={(variant.actionOne || variant.actionTwo) ? + <> + {variant.actionOne && + + + +
+
+
+ + + + +
+
+
SECONDARY
This is a secondary alert +
+
+
+
+
+
+
+ +
+
+
SUCCESS
This is a success alert +
+
+
+
+
+
+
+ +
+
+
ERROR
This is a error alert +
+
+
+
+
+
+
+ +
+
+
WARNING
This is a warning alert +
+
+
+
+
+
+
+ + + + +
+
+
INFO
This is a info alert +
+
+
+
+" +`; + exports[`AppTitle should render examples: AppTitle 1`] = ` "

Drive

@@ -107,7 +207,7 @@ exports[`Badge should render examples: Badge 1`] = `
" `; -exports[`Badge should render examples: Badge 2`] = `"
CD
"`; +exports[`Badge should render examples: Badge 2`] = `"
CD
"`; exports[`Banner should render examples: Banner 1`] = ` "
@@ -2399,187 +2499,187 @@ exports[`DropdownText should render examples: DropdownText 1`] = ` "
Default
-
-

h1

-

+

+

h1

+

-
-

h2

-

+

+

h2

+

-
-

h3

-

+

+

h3

+

-
-

h4

-

+

+

h4

+

-
-
h5
-

+

+
h5
+

-
-
subtitle1
-

+

+
subtitle1
+

-
-
subtitle2
-

+

+
subtitle2
+

-
-

body1

-

+

+

body1

+

-
-

body2

-

+

+

body2

+

-
caption -

+

caption +

Disabled
-
-

h1

-

+

+

h1

+

-
-

h2

-

+

+

h2

+

-
-

h3

-

+

+

h3

+

-
-

h4

-

+

+

h4

+

-
-
h5
-

+

+
h5
+

-
-
subtitle1
-

+

+
subtitle1
+

-
-
subtitle2
-

+

+
subtitle2
+

-
-

body1

-

+

+

body1

+

-
-

body2

-

+

+

body2

+

-
caption -

+

caption +

-
-

This is a long text without ellipsis

-

+

+

This is a long text without ellipsis

+

-
-

This is a long text with ellipsis

-

+

+

This is a long text with ellipsis

+

-
-

Space between text and icon

-

+

+

Space between text and icon

+

-
-

Text with
breaking spaces
inside content

-

+

+

Text with
breaking spaces
inside content

+

@@ -2954,98 +3054,98 @@ exports[`Icon should render examples: Icon 1`] = ` "

Font size: 16px

-
+

Album

-
+

AlbumAdd

-
+

AlbumRemove

-
+

Answer

-
+

Apple

-
+

Archive

-
+

Attachment

-
+

Attention

-
+

Bank

-
+

Banking

-
+

BankingAdd

-
+

Bell

-
+

Bike

-
+

Bill

-
+

Bottom

-
+

BrowserBrave

-
+

BrowserChrome

-
+

BrowserDuckduckgo

-
+
@@ -3053,108 +3153,108 @@ exports[`Icon should render examples: Icon 1`] = `

BrowserEdge

-
+

BrowserEdgeChromium

-
+

BrowserFirefox

-
+

BrowserIe

-
+

BrowserOpera

-
+

BrowserSafari

-
+

Burger

-
+

Bus

-
+

Calendar

-
+

Camera

-
+

Car

-
+

CarbonCopy

-
+

Categories

-
+

Certified

-
+

Check

-
+

Checkbox

-
+

CheckCircle

-
+

CheckList

-
+

CheckSquare

-
+

CircleFilled

-
+

Clock

-
+
@@ -3164,58 +3264,58 @@ exports[`Icon should render examples: Icon 1`] = `

Cloud

-
+

CloudHappy

-
+

Collect

-
+

Comment

-
+

Company

-
+

Compass

-
+

Connector

-
+

Contract

-
+

Contrast

-
+

CozyLaugh

-
+

CozyText

-
+
@@ -3223,57 +3323,57 @@ exports[`Icon should render examples: Icon 1`] = `

Credit

-
+

CreditCard

-
+

CreditCardAdd

-
+

Crop

-
+

Cross

-
+

CrossCircle

-
+

CrossSmall

-
+

Cube

-
+

Dash

-
+

Dashboard

-
+

DataControl

-
+
@@ -3281,82 +3381,82 @@ exports[`Icon should render examples: Icon 1`] = `

Debit

-
+

Devices

-
+

Dots

-
+

Down

-
+

Download

-
+

DrawingArrowUp

-
+

Dropdown

-
+

DropdownClose

-
+

DropdownOpen

-
+

Dropup

-
+

Email

-
+

EmailNotification

-
+

Eu

-
+

Euro

-
+

Exchange

-
+

Eye

-
+
@@ -3365,7 +3465,7 @@ exports[`Icon should render examples: Icon 1`] = `

EyeClosed

-
+
@@ -3373,12 +3473,12 @@ exports[`Icon should render examples: Icon 1`] = `

File

-
+

FileAdd

-
+
@@ -3388,12 +3488,12 @@ exports[`Icon should render examples: Icon 1`] = `

FileDuotone

-
+

FileNew

-
+
@@ -3401,47 +3501,47 @@ exports[`Icon should render examples: Icon 1`] = `

FileNone

-
+

FileOutline

-
+

Filter

-
+

Fingerprint

-
+

Fitness

-
+

Flag

-
+

FlagOutlined

-
+

FlashAuto

-
+

Flashlight

-
+
@@ -3449,27 +3549,27 @@ exports[`Icon should render examples: Icon 1`] = `

Folder

-
+

FolderAdd

-
+

FolderMoveto

-
+

Forbidden

-
+

FromUser

-
+
@@ -3477,57 +3577,57 @@ exports[`Icon should render examples: Icon 1`] = `

Gear

-
+

Globe

-
+

GraphCircle

-
+

Grid

-
+

GroupList

-
+

Groups

-
+

Hand

-
+

Heart

-
+

Help

-
+

History

-
+

Home

-
+
@@ -3535,12 +3635,12 @@ exports[`Icon should render examples: Icon 1`] = `

Hourglass

-
+

Image

-
+
@@ -3548,87 +3648,87 @@ exports[`Icon should render examples: Icon 1`] = `

Info

-
+

InfoOutlined

-
+

Key

-
+

Laptop

-
+

Left

-
+

Lightbulb

-
+

Link

-
+

LinkOut

-
+

List

-
+

Location

-
+

Lock

-
+

Logout

-
+

MagicTrick

-
+

Magnet

-
+

Magnifier

-
+

Merge

-
+

Mountain

-
+
@@ -3636,7 +3736,7 @@ exports[`Icon should render examples: Icon 1`] = `

MovementIn

-
+
@@ -3644,82 +3744,82 @@ exports[`Icon should render examples: Icon 1`] = `

MovementOut

-
+

Movement

-
+

Moveto

-
+

MultiFiles

-
+

Music

-
+

New

-
+

Next

-
+

Note

-
+

NotificationEmail

-
+

Offline

-
+

Online

-
+

Openwith

-
+

Palette

-
+

Paper

-
+

Paperplane

-
+

Password

-
+
@@ -3727,57 +3827,57 @@ exports[`Icon should render examples: Icon 1`] = `

Pen

-
+

People

-
+

Percent

-
+

PercentCircle

-
+

PersonalData

-
+

Phone

-
+

PhoneDownload

-
+

PhoneUpload

-
+

PieChart

-
+

Pin

-
+

Plane

-
+
@@ -3785,7 +3885,7 @@ exports[`Icon should render examples: Icon 1`] = `

Plus

-
+
@@ -3793,57 +3893,57 @@ exports[`Icon should render examples: Icon 1`] = `

PlusSmall

-
+

Previous

-
+

Printer

-
+

Qualify

-
+

RadioChecked

-
+

RadioUnchecked

-
+

Rename

-
+

Repare

-
+

Reply

-
+

Restaurant

-
+

RestoreStraight

-
+
@@ -3851,52 +3951,52 @@ exports[`Icon should render examples: Icon 1`] = `

Restore

-
+

Right

-
+

Rise

-
+

RotateLeft

-
+

RotateRight

-
+

SadCozy

-
+

Safe

-
+

School

-
+

SelectAll

-
+

Setting

-
+
@@ -3904,58 +4004,58 @@ exports[`Icon should render examples: Icon 1`] = `

Share

-
+

ShareCircle

-
+

Shield

-
+

Shop

-
+

Sound

-
+

Spinner

-
+

Stack

-
+

Star

-
+

Stats

-
+

Subway

-
+

Sync

-
+

SyncCozy

@@ -3966,37 +4066,37 @@ exports[`Icon should render examples: Icon 1`] = `

Tag

-
+

Target

-
+

Team

-
+

Telephone

-
+

ToTheCloud

-
+

Top

-
+

Train

-
+
@@ -4004,77 +4104,77 @@ exports[`Icon should render examples: Icon 1`] = `

Trash

-
+

Trophy

-
+

Unknow

-
+

Unlink

-
+

Unlock

-
+

Up

-
+

Upload

-
+

Videos

-
+

Walk

-
+

Wallet

-
+

WalletAdd

-
+

WalletNew

-
+

Warn

-
+

Warning

-
+

WarningCircle

-
+

WrenchCircle

@@ -7854,13 +7954,13 @@ exports[`Media should render examples: Media 3`] = ` exports[`MuiCozyTheme/Switch should render examples: MuiCozyTheme/Switch 1`] = ` "
-
+

primary

-
+

secondary

-
+

default

@@ -7895,42 +7995,42 @@ exports[`Paper should render examples: Paper 1`] = `
Variant selector
-
+

This is a sheet of paper

elevation 0

Paper can be used to build surface or other elements for your application.

-
+

This is a sheet of paper

elevation 1

Paper can be used to build surface or other elements for your application.

-
+

This is a sheet of paper

elevation 4

Paper can be used to build surface or other elements for your application.

-
+

This is a sheet of paper

elevation 12

Paper can be used to build surface or other elements for your application.

-
+

This is a sheet of paper

elevation 16

Paper can be used to build surface or other elements for your application.

-
+

This is a sheet of paper

elevation 24
@@ -7964,20 +8064,20 @@ exports[`PieChart should render examples: PieChart 1`] = ` "
-
-
-
-

60 %

-

of the total

+
+
+
+

60 %

+

of the total

-
-
-
-

105 €

-

on the period

+
+
+
+

105 €

+

on the period

@@ -8005,7 +8105,7 @@ exports[`ProgressionBanner should render examples: ProgressionBanner 1`] = `
Variant selector
-
+
@@ -8024,7 +8124,7 @@ exports[`ProgressionBanner should render examples: ProgressionBanner 1`] = `

-
+
diff --git a/react/examples.spec.jsx b/react/examples.spec.jsx index 92b1ecc722..32187cf35b 100644 --- a/react/examples.spec.jsx +++ b/react/examples.spec.jsx @@ -24,6 +24,7 @@ const testComponent = (ComponentName, options) => { } // Please keep the list sorted +testComponent('Alert') testComponent('AppTitle') testComponent('Avatar') testComponent('Badge') diff --git a/react/index.js b/react/index.js index 09f123b630..aef76422b9 100644 --- a/react/index.js +++ b/react/index.js @@ -106,3 +106,5 @@ export { default as Chips } from './Chips' export { default as PieChart } from './PieChart' export { default as DropdownText } from './DropdownText' export { default as CircleButton } from './CircleButton' +export { default as Alert } from './Alert' +export { default as AlertTitle } from './AlertTitle'