diff --git a/docs/documentation/components/menu.mdx b/docs/documentation/components/menu.mdx
index d65a60e19..c22240fee 100644
--- a/docs/documentation/components/menu.mdx
+++ b/docs/documentation/components/menu.mdx
@@ -181,7 +181,7 @@ function MenuOptionsGroupExample() {
{ label: 'Descending', value: 'desc' },
]}
selected={selectedOrder}
- onChange={selected => setSelectedOrder(selected)}
+ onChange={(selected) => setSelectedOrder(selected)}
/>
setSelectedField(selected)}
+ onChange={(selected) => setSelectedField(selected)}
/>
)
@@ -209,33 +209,33 @@ either have `[role="menuitemradio"]` or `[role="menuitem"]`.
The focus styles are currently not working in the docs, sorry for the inconvenience!
```jsx
-
-
-
- }
->
- Custom Menu Items
-
+function CustomMenuItemExample() {
+ const handleClick = React.useCallback(() => toaster.notify('Menu Item Clicked'), [])
+
+ return (
+
+
+
+ Hey Evergreen,
+
+
+ I want custom items
+
+
+
+ Oh sweet
+
+
+
+ }
+ >
+ Custom Menu Items
+
+ )
+}
```
## Menu without items
diff --git a/docs/documentation/components/tag-input.mdx b/docs/documentation/components/tag-input.mdx
index 91c4f8ff5..7f7c5a0e6 100644
--- a/docs/documentation/components/tag-input.mdx
+++ b/docs/documentation/components/tag-input.mdx
@@ -145,7 +145,10 @@ manually controlled. `TagInput` will not remove items from this list after they
function AutoCompleteTagInputExample() {
const [values, setValues] = React.useState(['First', 'Second'])
- const allValues = ['First', 'Second', 'Third', 'Fourth', 'Fifth', 'Sixth', 'Seventh', 'Eighth', 'Ninth', 'Tenth']
+ const allValues = React.useMemo(
+ () => ['First', 'Second', 'Third', 'Fourth', 'Fifth', 'Sixth', 'Seventh', 'Eighth', 'Ninth', 'Tenth'],
+ []
+ )
const autocompleteItems = React.useMemo(() => allValues.filter((i) => !values.includes(i)), [allValues, values])
return (
diff --git a/docs/documentation/components/toaster.mdx b/docs/documentation/components/toaster.mdx
index 776f3b761..6b492b61c 100644
--- a/docs/documentation/components/toaster.mdx
+++ b/docs/documentation/components/toaster.mdx
@@ -41,39 +41,25 @@ The `toaster` is an instance of the `Toaster` class.
## Notify
```jsx
- toaster.notify('Evergreen is a open-source design system')}
->
- Notify
-
+ toaster.notify('Evergreen is an open-source design system')}>Notify
```
## Success
```jsx
- toaster.success('Your source is now sending data')}>
- Success
-
+ toaster.success('Your source is now sending data')}>Success
```
## Warning
```jsx
- toaster.warning('Changes will affect all Warehouses')}>
- Warning
-
+ toaster.warning('Changes will affect all Warehouses')}>Warning
```
## Danger
```jsx
-
- toaster.danger('Something went wrong trying to create your audience')
- }
->
- Danger
-
+ toaster.danger('Something went wrong trying to create your audience')}>Danger
```
## Close all
@@ -91,7 +77,7 @@ The description can be a React node.
toaster.success('Your source is now sending data', {
- description: 'Connect your source to a destination to receive data.'
+ description: 'Connect your source to a destination to receive data.',
})
}
>
@@ -109,7 +95,7 @@ The `duration` property is in seconds — not milliseconds.
toaster.success('Stick around for 10 seconds', {
- duration: 10
+ duration: 10,
})
}
>
@@ -126,7 +112,7 @@ Passing a unique ID via `id` property allows Evergreen to close all previous toa
toaster.warning('Only one toaster will be shown', {
- id: 'forbidden-action'
+ id: 'forbidden-action',
})
}
>
diff --git a/docs/fixtures/profiles.json b/docs/fixtures/profiles.json
index d679138ab..b6797d423 100644
--- a/docs/fixtures/profiles.json
+++ b/docs/fixtures/profiles.json
@@ -1,842 +1,242 @@
[
{
+ "id": "1",
"lastActivity": "a few seconds ago",
- "void": " ",
"ltv": "$365",
- "id": "1",
- "status": "regular",
- "image": "assets/Female/Cheryl-Carter.jpg",
- "icon": "message",
- "city": "San Francisco",
- "job": "Senior Financial Analyst",
- "company": "Skyble",
- "description": "Senior Financial Analyst, Skyble",
- "country": "United States",
- "gender": "Female",
- "firstname": "Cheryl",
- "lastname": "Carter",
- "name": "Cheryl Carter",
- "email": "cheryl@skyble.com",
- "phone": "2-(017)772-7449",
- "address": "396 Calypso Parkway"
+ "name": "Cheryl Carter"
},
{
+ "id": "2",
"lastActivity": "a minute ago",
- "void": " ",
"ltv": "$427",
- "id": "2",
- "status": "VIP",
- "image": "assets/Female/Heather-Morales.jpg",
- "icon": "phone",
- "city": "Zelenogradsk",
- "job": "Analyst Programmer",
- "company": "Yambee",
- "description": "Analyst Programmer, Yambee",
- "country": "Russia",
- "gender": "Female",
- "firstname": "Heather",
- "lastname": "Morales",
- "name": "Heather Morales",
- "email": "hmorales1@un.org",
- "phone": "7-(897)249-9830",
- "address": "42604 Scofield Center"
+ "name": "Heather Morales"
},
{
+ "id": "3",
"lastActivity": "3 minutes ago",
- "void": " ",
"ltv": "$538",
- "id": "3",
- "status": "VIP",
- "image": "assets/Male/Sean-Jackson.jpg",
- "icon": "phone",
- "city": "Yongqin",
- "job": "Structural Engineer",
- "company": "Linkbridge",
- "description": "Structural Engineer, Linkbridge",
- "country": "China",
- "gender": "Male",
- "firstname": "Sean",
- "lastname": "Jackson",
- "name": "Sean Jackson",
- "email": "sjackson2@youtu.be",
- "phone": "6-(527)389-6219",
- "address": "66529 Eagle Crest Junction"
+ "name": "Sean Jackson"
},
{
+ "id": "4",
"lastActivity": "4 minutes ago",
- "void": " ",
"ltv": "$171",
- "id": "4",
- "status": "regular",
- "image": "assets/Female/Catherine-Anderson.jpg",
- "icon": "message",
- "city": "Haarlem",
- "job": "Data Coordiator",
- "company": "Jaloo",
- "description": "Data Coordiator, Jaloo",
- "country": "Netherlands",
- "gender": "Female",
- "firstname": "Catherine",
- "lastname": "Anderson",
- "name": "Catherine Anderson",
- "email": "canderson3@theguardian.com",
- "phone": "7-(464)124-7393",
- "address": "94940 Marcy Terrace"
+ "name": "Catherine Anderson"
},
{
+ "id": "5",
"lastActivity": "6 minutes ago",
- "void": " ",
"ltv": "$222",
- "id": "5",
- "status": "regular",
- "image": "assets/Male/Jack-Phillips.jpg",
- "icon": "email",
- "city": "Rawang",
- "job": "Compensation Analyst",
- "company": "Aimbu",
- "description": "Compensation Analyst, Aimbu",
- "country": "Malaysia",
- "gender": "Male",
- "firstname": "Jack",
- "lastname": "Phillips",
- "name": "Jack Phillips",
- "email": "jphillips4@addthis.com",
- "phone": "1-(876)685-7879",
- "address": "32 Ridge Oak Hill"
+ "name": "Jack Phillips"
},
{
+ "id": "6",
"lastActivity": "7 minutes ago",
- "void": " ",
"ltv": "$365",
- "id": "6",
- "status": "VIP",
- "image": "assets/Female/Julia-Williamson.jpg",
- "icon": "phone",
- "city": "Lhuentse",
- "job": "Account Representative II",
- "company": "Dabjam",
- "description": "Account Representative II, Dabjam",
- "country": "Bhutan",
- "gender": "Female",
- "firstname": "Julia",
- "lastname": "Williamson",
- "name": "Julia Williamson",
- "email": "jwilliamson5@elegantthemes.com",
- "phone": "5-(363)496-4627",
- "address": "5702 Corben Way"
+ "name": "Julia Williamson"
},
{
+ "id": "7",
"lastActivity": "8 minutes ago",
- "void": " ",
"ltv": "$392",
- "id": "7",
- "status": "regular",
- "image": "assets/Male/Jonathan-Martin.jpg",
- "icon": "message",
- "city": "Huatan",
- "job": "Mechanical Systems Engineer",
- "company": "Browsezoom",
- "description": "Mechanical Systems Engineer, Browsezoom",
- "country": "China",
- "gender": "Male",
- "firstname": "Jonathan",
- "lastname": "Martin",
- "name": "Jonathan Martin",
- "email": "jmartin6@cnn.com",
- "phone": "0-(497)996-6818",
- "address": "097 Springs Terrace"
+ "name": "Jonathan Martin"
},
{
+ "id": "8",
"lastActivity": "10 minutes ago",
- "void": " ",
"ltv": "$795",
- "id": "8",
- "status": "regular",
- "image": "assets/Female/Maria-Bennett.jpg",
- "icon": "email",
- "city": "Shimodate",
- "job": "Recruiter",
- "company": "Twitterlist",
- "description": "Recruiter, Twitterlist",
- "country": "Japan",
- "gender": "Female",
- "firstname": "Maria",
- "lastname": "Bennett",
- "name": "Maria Bennett",
- "email": "mbennett7@blogger.com",
- "phone": "7-(138)318-9102",
- "address": "0413 Independence Street"
+ "name": "Maria Bennett"
},
{
+ "id": "9",
"lastActivity": "11 minutes ago",
- "void": " ",
"ltv": "$844",
- "id": "9",
- "status": "regular",
- "image": "assets/Female/Sarah-Garrett.jpg",
- "icon": "email",
- "city": "Gushui",
- "job": "Mechanical Systems Engineer",
- "company": "Miboo",
- "description": "Mechanical Systems Engineer, Miboo",
- "country": "China",
- "gender": "Female",
- "firstname": "Sarah",
- "lastname": "Garrett",
- "name": "Sarah Garrett",
- "email": "sgarrett8@marriott.com",
- "phone": "8-(715)208-6651",
- "address": "7 Dwight Center"
+ "name": "Sarah Garrett"
},
{
+ "id": "10",
"lastActivity": "13 minutes ago",
- "void": " ",
"ltv": "$430",
- "id": "10",
- "status": "regular",
- "image": "assets/Male/Carl-Barnes.jpg",
- "icon": "message",
- "city": "Pancanagara",
- "job": "Teacher",
- "company": "Meezzy",
- "description": "Teacher, Meezzy",
- "country": "Indonesia",
- "gender": "Male",
- "firstname": "Carl",
- "lastname": "Barnes",
- "name": "Carl Barnes",
- "email": "cbarnes9@pagesperso-orange.fr",
- "phone": "9-(536)901-4418",
- "address": "8 Orin Junction"
+ "name": "Carl Barnes"
},
{
+ "id": "11",
"lastActivity": "14 minutes ago",
- "void": " ",
"ltv": "$872",
- "id": "11",
- "status": "regular",
- "image": "assets/Male/Aaron-Turner.jpg",
- "icon": "message",
- "city": "Zhouzhuang",
- "job": "Community Outreach Specialist",
- "company": "Demimbu",
- "description": "Community Outreach Specialist, Demimbu",
- "country": "China",
- "gender": "Male",
- "firstname": "Aaron",
- "lastname": "Turner",
- "name": "Aaron Turner",
- "email": "aturnera@noaa.gov",
- "phone": "9-(596)830-7369",
- "address": "1 Lunder Road"
+ "name": "Aaron Turner"
},
{
+ "id": "12",
"lastActivity": "15 minutes ago",
- "void": " ",
"ltv": "$997",
- "id": "12",
- "status": "VIP",
- "image": "assets/Male/Billy-Reed.jpg",
- "icon": "email",
- "city": "Djounie",
- "job": "Account Representative III",
- "company": "Mycat",
- "description": "Account Representative III, Mycat",
- "country": "Lebanon",
- "gender": "Male",
- "firstname": "Billy",
- "lastname": "Reed",
- "name": "Billy Reed",
- "email": "breedb@qq.com",
- "phone": "6-(665)777-5744",
- "address": "75 Bayside Trail"
+ "name": "Billy Reed"
},
{
+ "id": "13",
"lastActivity": "17 minutes ago",
- "void": " ",
"ltv": "$275",
- "id": "13",
- "status": "regular",
- "image": "assets/Female/Anna-Fuller.jpg",
- "icon": "phone",
- "city": "Turenki",
- "job": "Desktop Support Technician",
- "company": "Rhyloo",
- "description": "Desktop Support Technician, Rhyloo",
- "country": "Finland",
- "gender": "Female",
- "firstname": "Anna",
- "lastname": "Fuller",
- "name": "Anna Fuller",
- "email": "afullerc@buzzfeed.com",
- "phone": "8-(436)008-0813",
- "address": "02049 Cascade Circle"
+ "name": "Anna Fuller"
},
{
+ "id": "14",
"lastActivity": "18 minutes ago",
- "void": " ",
"ltv": "$359",
- "id": "14",
- "status": "regular",
- "image": "assets/Female/Linda-Torres.jpg",
- "icon": "message",
- "city": "Fier-Çifçi",
- "job": "Analyst Programmer",
- "company": "Avavee",
- "description": "Analyst Programmer, Avavee",
- "country": "Albania",
- "gender": "Female",
- "firstname": "Linda",
- "lastname": "Torres",
- "name": "Linda Torres",
- "email": "ltorresd@naver.com",
- "phone": "8-(279)165-4756",
- "address": "15 Morrow Crossing"
+ "name": "Linda Torres"
},
{
+ "id": "15",
"lastActivity": "20 minutes ago",
- "void": " ",
"ltv": "$270",
- "id": "15",
- "status": "VIP",
- "image": "assets/Female/Angela-Allen.jpg",
- "icon": "email",
- "city": "Bau",
- "job": "Financial Advisor",
- "company": "Yodel",
- "description": "Financial Advisor, Yodel",
- "country": "Indonesia",
- "gender": "Female",
- "firstname": "Angela",
- "lastname": "Allen",
- "name": "Angela Allen",
- "email": "aallene@canalblog.com",
- "phone": "3-(293)300-1783",
- "address": "06073 Ruskin Trail"
+ "name": "Angela Allen"
},
{
+ "id": "16",
"lastActivity": "21 minutes ago",
- "void": " ",
"ltv": "$314",
- "id": "16",
- "status": "regular",
- "image": "assets/Female/Phyllis-Perkins.jpg",
- "icon": "phone",
- "city": "Irkutsk",
- "job": "Associate Professor",
- "company": "Gigaclub",
- "description": "Associate Professor, Gigaclub",
- "country": "Russia",
- "gender": "Female",
- "firstname": "Phyllis",
- "lastname": "Perkins",
- "name": "Phyllis Perkins",
- "email": "pperkinsf@redcross.org",
- "phone": "8-(460)060-6595",
- "address": "49 Cody Crossing"
+ "name": "Phyllis Perkins"
},
{
+ "id": "17",
"lastActivity": "22 minutes ago",
- "void": " ",
"ltv": "$116",
- "id": "17",
- "status": "VIP",
- "image": "assets/Female/Marilyn-Fuller.jpg",
- "icon": "message",
- "city": "Jiashi",
- "job": "Environmental Tech",
- "company": "Fivechat",
- "description": "Environmental Tech, Fivechat",
- "country": "China",
- "gender": "Female",
- "firstname": "Marilyn",
- "lastname": "Fuller",
- "name": "Marilyn Fuller",
- "email": "mfullerg@wikispaces.com",
- "phone": "1-(679)604-6372",
- "address": "07 Anniversary Circle"
+ "name": "Marilyn Fuller"
},
{
+ "id": "18",
"lastActivity": "24 minutes ago",
- "void": " ",
"ltv": "$192",
- "id": "18",
- "status": "regular",
- "image": "assets/Male/Ryan-Alvarez.jpg",
- "icon": "email",
- "city": "Junliangcheng",
- "job": "Engineer IV",
- "company": "Skaboo",
- "description": "Engineer IV, Skaboo",
- "country": "China",
- "gender": "Male",
- "firstname": "Ryan",
- "lastname": "Alvarez",
- "name": "Ryan Alvarez",
- "email": "ralvarezh@yahoo.com",
- "phone": "0-(069)397-9898",
- "address": "44 Farmco Hill"
+ "name": "Ryan Alvarez"
},
{
+ "id": "19",
"lastActivity": "25 minutes ago",
- "void": " ",
"ltv": "$520",
- "id": "19",
- "status": "regular",
- "image": "assets/Male/Fred-Lane.jpg",
- "icon": "message",
- "city": "Songwon",
- "job": "Professor",
- "company": "Browsedrive",
- "description": "Professor, Browsedrive",
- "country": "South Korea",
- "gender": "Male",
- "firstname": "Fred",
- "lastname": "Lane",
- "name": "Fred Lane",
- "email": "flanei@homestead.com",
- "phone": "4-(234)399-6849",
- "address": "96 Hovde Lane"
+ "name": "Fred Lane"
},
{
+ "id": "20",
"lastActivity": "27 minutes ago",
- "void": " ",
"ltv": "$702",
- "id": "20",
- "status": "VIP",
- "image": "assets/Female/Jane-Sims.jpg",
- "icon": "phone",
- "city": "Příšovice",
- "job": "Senior Sales Associate",
- "company": "Linktype",
- "description": "Senior Sales Associate, Linktype",
- "country": "Czech Republic",
- "gender": "Female",
- "firstname": "Jane",
- "lastname": "Sims",
- "name": "Jane Sims",
- "email": "jsimsj@ehow.com",
- "phone": "5-(441)244-0495",
- "address": "53960 Straubel Trail"
+ "name": "Jane Sims"
},
{
+ "id": "21",
"lastActivity": "28 minutes ago",
- "void": " ",
"ltv": "$771",
- "id": "21",
- "status": "regular",
- "image": "assets/Female/Angela-Ellis.jpg",
- "icon": "phone",
- "city": "Kitango",
- "job": "Professor",
- "company": "Bubbletube",
- "description": "Professor, Bubbletube",
- "country": "Philippines",
- "gender": "Female",
- "firstname": "Angela",
- "lastname": "Ellis",
- "name": "Angela Ellis",
- "email": "aellisk@opera.com",
- "phone": "3-(960)622-6113",
- "address": "57 Jackson Lane"
+ "name": "Angela Ellis"
},
{
+ "id": "22",
"lastActivity": "29 minutes ago",
- "void": " ",
"ltv": "$849",
- "id": "22",
- "status": "regular",
- "image": "assets/Female/Diane-Dunn.jpg",
- "icon": "email",
- "city": "Cawalo",
- "job": "Editor",
- "company": "Photojam",
- "description": "Editor, Photojam",
- "country": "Indonesia",
- "gender": "Female",
- "firstname": "Diane",
- "lastname": "Dunn",
- "name": "Diane Dunn",
- "email": "ddunnl@cafepress.com",
- "phone": "8-(654)421-6804",
- "address": "249 Macpherson Court"
+ "name": "Diane Dunn"
},
{
+ "id": "23",
"lastActivity": "31 minutes ago",
- "void": " ",
"ltv": "$439",
- "id": "23",
- "status": "VIP",
- "image": "assets/Male/Timothy-Duncan.jpg",
- "icon": "email",
- "city": "Upper Hell's Gate",
- "job": "Chief Design Engineer",
- "company": "Fivespan",
- "description": "Chief Design Engineer, Fivespan",
- "country": "Bonaire, Saint Eustatius and Saba ",
- "gender": "Male",
- "firstname": "Timothy",
- "lastname": "Duncan",
- "name": "Timothy Duncan",
- "email": "tduncanm@so-net.ne.jp",
- "phone": "3-(256)693-9539",
- "address": "97 Jenna Trail"
+ "name": "Timothy Duncan"
},
{
+ "id": "24",
"lastActivity": "32 minutes ago",
- "void": " ",
"ltv": "$31",
- "id": "24",
- "status": "regular",
- "image": "assets/Male/Ronald-Mendoza.jpg",
- "icon": "message",
- "city": "Dobropillya",
- "job": "Help Desk Operator",
- "company": "Skinte",
- "description": "Help Desk Operator, Skinte",
- "country": "Ukraine",
- "gender": "Male",
- "firstname": "Ronald",
- "lastname": "Mendoza",
- "name": "Ronald Mendoza",
- "email": "rmendozan@newsvine.com",
- "phone": "8-(499)733-7484",
- "address": "2 Delaware Crossing"
+ "name": "Ronald Mendoza"
},
{
+ "id": "25",
"lastActivity": "34 minutes ago",
- "void": " ",
"ltv": "$862",
- "id": "25",
- "status": "regular",
- "image": "assets/Male/Michael-Gilbert.jpg",
- "icon": "phone",
- "city": "Cuamba",
- "job": "Nuclear Power Engineer",
- "company": "Jaloo",
- "description": "Nuclear Power Engineer, Jaloo",
- "country": "Mozambique",
- "gender": "Male",
- "firstname": "Michael",
- "lastname": "Gilbert",
- "name": "Michael Gilbert",
- "email": "mgilberto@technorati.com",
- "phone": "3-(846)455-2798",
- "address": "8 Village Green Circle"
+ "name": "Michael Gilbert"
},
{
+ "id": "26",
"lastActivity": "35 minutes ago",
- "void": " ",
"ltv": "$897",
- "id": "26",
- "status": "VIP",
- "image": "assets/Female/Kathryn-Fuller.jpg",
- "icon": "email",
- "city": "Chosica",
- "job": "Staff Scientist",
- "company": "Bubblebox",
- "description": "Staff Scientist, Bubblebox",
- "country": "Peru",
- "gender": "Female",
- "firstname": "Kathryn",
- "lastname": "Fuller",
- "name": "Kathryn Fuller",
- "email": "kfullerp@utexas.edu",
- "phone": "4-(497)438-9857",
- "address": "49 Katie Center"
+ "name": "Kathryn Fuller"
},
{
+ "id": "27",
"lastActivity": "36 minutes ago",
- "void": " ",
"ltv": "$248",
- "id": "27",
- "status": "regular",
- "image": "assets/Male/Ralph-Larson.jpg",
- "icon": "email",
- "city": "Talitsy",
- "job": "Assistant Manager",
- "company": "Yakidoo",
- "description": "Assistant Manager, Yakidoo",
- "country": "Russia",
- "gender": "Male",
- "firstname": "Ralph",
- "lastname": "Larson",
- "name": "Ralph Larson",
- "email": "rlarsonq@stumbleupon.com",
- "phone": "4-(868)508-6096",
- "address": "6504 Stoughton Pass"
+ "name": "Ralph Larson"
},
{
+ "id": "28",
"lastActivity": "38 minutes ago",
- "void": " ",
"ltv": "$372",
- "id": "28",
- "status": "VIP",
- "image": "assets/Female/Karen-Wagner.jpg",
- "icon": "message",
- "city": "Santa Rosa de Lima",
- "job": "VP Accounting",
- "company": "Thoughtworks",
- "description": "VP Accounting, Thoughtworks",
- "country": "El Salvador",
- "gender": "Female",
- "firstname": "Karen",
- "lastname": "Wagner",
- "name": "Karen Wagner",
- "email": "kwagnerr@goodreads.com",
- "phone": "1-(780)689-1341",
- "address": "71 Rutledge Lane"
+ "name": "Karen Wagner"
},
{
+ "id": "29",
"lastActivity": "39 minutes ago",
- "void": " ",
"ltv": "$945",
- "id": "29",
- "status": "regular",
- "image": "assets/Female/Christina-Morales.jpg",
- "icon": "phone",
- "city": "Petrópolis",
- "job": "Staff Scientist",
- "company": "Yoveo",
- "description": "Staff Scientist, Yoveo",
- "country": "Brazil",
- "gender": "Female",
- "firstname": "Christina",
- "lastname": "Morales",
- "name": "Christina Morales",
- "email": "cmoraless@stumbleupon.com",
- "phone": "4-(319)232-1760",
- "address": "89 Wayridge Center"
+ "name": "Christina Morales"
},
{
+ "id": "30",
"lastActivity": "41 minutes ago",
- "void": " ",
"ltv": "$862",
- "id": "30",
- "status": "VIP",
- "image": "assets/Male/Daniel-Palmer.jpg",
- "icon": "email",
- "city": "Abang",
- "job": "Sales Associate",
- "company": "Fliptune",
- "description": "Sales Associate, Fliptune",
- "country": "Indonesia",
- "gender": "Male",
- "firstname": "Daniel",
- "lastname": "Palmer",
- "name": "Daniel Palmer",
- "email": "dpalmert@ox.ac.uk",
- "phone": "2-(828)639-6922",
- "address": "0 Anthes Alley"
+ "name": "Daniel Palmer"
},
{
+ "id": "31",
"lastActivity": "42 minutes ago",
- "void": " ",
"ltv": "$346",
- "id": "31",
- "status": "regular",
- "image": "assets/Male/Joshua-Murray.jpg",
- "icon": "email",
- "city": "Carapelhos",
- "job": "Senior Quality Engineer",
- "company": "Quimm",
- "description": "Senior Quality Engineer, Quimm",
- "country": "Portugal",
- "gender": "Male",
- "firstname": "Joshua",
- "lastname": "Murray",
- "name": "Joshua Murray",
- "email": "jmurrayu@statcounter.com",
- "phone": "2-(732)633-4593",
- "address": "544 Hovde Lane"
+ "name": "Joshua Murray"
},
{
+ "id": "32",
"lastActivity": "43 minutes ago",
- "void": " ",
"ltv": "$858",
- "id": "32",
- "status": "VIP",
- "image": "assets/Male/Timothy-West.jpg",
- "icon": "email",
- "city": "Carauari",
- "job": "Nurse",
- "company": "Edgetag",
- "description": "Nurse, Edgetag",
- "country": "Brazil",
- "gender": "Male",
- "firstname": "Timothy",
- "lastname": "West",
- "name": "Timothy West",
- "email": "twestv@blogtalkradio.com",
- "phone": "7-(571)378-0199",
- "address": "4 Darwin Street"
+ "name": "Timothy West"
},
{
+ "id": "33",
"lastActivity": "an hour ago",
- "void": " ",
"ltv": "$39",
- "id": "33",
- "status": "regular",
- "image": "assets/Male/Martin-Bradley.jpg",
- "icon": "phone",
- "city": "Longjumeau",
- "job": "Pharmacist",
- "company": "Jabbercube",
- "description": "Pharmacist, Jabbercube",
- "country": "France",
- "gender": "Male",
- "firstname": "Martin",
- "lastname": "Bradley",
- "name": "Martin Bradley",
- "email": "mbradleyw@umn.edu",
- "phone": "7-(696)150-2845",
- "address": "0349 Farwell Road"
+ "name": "Martin Bradley"
},
{
+ "id": "34",
"lastActivity": "an hour ago",
- "void": " ",
"ltv": "$993",
- "id": "34",
- "status": "VIP",
- "image": "assets/Male/Philip-Hall.jpg",
- "icon": "phone",
- "city": "Mjölby",
- "job": "Senior Developer",
- "company": "Photofeed",
- "description": "Senior Developer, Photofeed",
- "country": "Sweden",
- "gender": "Male",
- "firstname": "Philip",
- "lastname": "Hall",
- "name": "Philip Hall",
- "email": "phallx@hao123.com",
- "phone": "2-(682)369-9988",
- "address": "7 Quincy Alley"
+ "name": "Philip Hall"
},
{
+ "id": "35",
"lastActivity": "an hour ago",
- "void": " ",
"ltv": "$83",
- "id": "35",
- "status": "regular",
- "image": "assets/Male/Keith-Willis.jpg",
- "icon": "phone",
- "city": "Stratónion",
- "job": "Senior Sales Associate",
- "company": "Eayo",
- "description": "Senior Sales Associate, Eayo",
- "country": "Greece",
- "gender": "Male",
- "firstname": "Keith",
- "lastname": "Willis",
- "name": "Keith Willis",
- "email": "kwillisy@uol.com.br",
- "phone": "2-(399)947-5764",
- "address": "6 Stoughton Place"
+ "name": "Keith Willis"
},
{
+ "id": "36",
"lastActivity": "an hour ago",
- "void": " ",
"ltv": "$465",
- "id": "36",
- "status": "VIP",
- "image": "assets/Female/Patricia-Harris.jpg",
- "icon": "message",
- "city": "La Victoria",
- "job": "Teacher",
- "company": "Fivespan",
- "description": "Teacher, Fivespan",
- "country": "Mexico",
- "gender": "Female",
- "firstname": "Patricia",
- "lastname": "Harris",
- "name": "Patricia Harris",
- "email": "pharrisz@dion.ne.jp",
- "phone": "1-(054)740-3188",
- "address": "97585 Russell Court"
+ "name": "Patricia Harris"
},
{
+ "id": "37",
"lastActivity": "an hour ago",
- "void": " ",
"ltv": "$616",
- "id": "37",
- "status": "regular",
- "image": "assets/Female/Frances-Nguyen.jpg",
- "icon": "email",
- "city": "Dabu",
- "job": "Information Systems Manager",
- "company": "Eabox",
- "description": "Information Systems Manager, Eabox",
- "country": "China",
- "gender": "Female",
- "firstname": "Frances",
- "lastname": "Nguyen",
- "name": "Frances Nguyen",
- "email": "fnguyen10@howstuffworks.com",
- "phone": "2-(351)004-9575",
- "address": "556 Monument Center"
+ "name": "Frances Nguyen"
},
{
+ "id": "38",
"lastActivity": "an hour ago",
- "void": " ",
"ltv": "$89",
- "id": "38",
- "status": "regular",
- "image": "assets/Male/Larry-Ward.jpg",
- "icon": "email",
- "city": "Zhangpu",
- "job": "Software Test Engineer I",
- "company": "Pixope",
- "description": "Software Test Engineer I, Pixope",
- "country": "China",
- "gender": "Male",
- "firstname": "Larry",
- "lastname": "Ward",
- "name": "Larry Ward",
- "email": "lward11@hubpages.com",
- "phone": "8-(432)794-0856",
- "address": "93283 Rutledge Drive"
+ "name": "Larry Ward"
},
{
+ "id": "39",
"lastActivity": "an hour ago",
- "void": " ",
"ltv": "$300",
- "id": "39",
- "status": "regular",
- "image": "assets/Male/Benjamin-Adams.jpg",
- "icon": "email",
- "city": "Pilaya",
- "job": "Junior Executive",
- "company": "Zooveo",
- "description": "Junior Executive, Zooveo",
- "country": "Bolivia",
- "gender": "Male",
- "firstname": "Benjamin",
- "lastname": "Adams",
- "name": "Benjamin Adams",
- "email": "badams12@unc.edu",
- "phone": "8-(255)674-7599",
- "address": "9282 Ramsey Center"
+ "name": "Benjamin Adams"
},
{
+ "id": "40",
"lastActivity": "an hour ago",
- "void": " ",
"ltv": "$936",
- "id": "40",
- "status": "VIP",
- "image": "assets/Female/Jane-James.jpg",
- "icon": "email",
- "city": "Połajewo",
- "job": "Biostatistician I",
- "company": "Miboo",
- "description": "Biostatistician I, Miboo",
- "country": "Poland",
- "gender": "Female",
- "firstname": "Jane",
- "lastname": "James",
- "name": "Jane James",
- "email": "jjames13@paginegialle.it",
- "phone": "0-(158)407-9506",
- "address": "3626 Eastwood Parkway"
+ "name": "Jane James"
}
]
diff --git a/docs/lib/codesandbox.ts b/docs/lib/codesandbox.ts
index dad293919..7bcaf7606 100644
--- a/docs/lib/codesandbox.ts
+++ b/docs/lib/codesandbox.ts
@@ -1,44 +1,38 @@
import LZString from 'lz-string'
import packageJson from '../package.json'
+import profiles from '../fixtures/profiles.json'
-function compress(string: string) {
- return LZString.compressToBase64(string).replace(/\+/g, `-`).replace(/\//g, `_`).replace(/=+$/, ``)
+/**
+ * Fixtures are static data that may be shared between examples or are large enough to distract
+ * from the example itself if placed in markdown.
+ */
+const fixtures = {
+ profiles,
}
-export const getCodeSandboxLink: (source: string) => string = (source) => {
- const wrappedSource = source.startsWith('function')
- ? source
- : `const Demo = () => {
- return (
- ${source}
- )
-}
- `
+export const getCodeSandboxLink = (source: string): string => {
+ const componentName = getComponentName(source)
- const componentName = source.startsWith('function')
- ? source.substring('function '.length, source.indexOf('('))
- : 'Demo'
+ const demoComponent = getDemoComponent(source)
- const usedComponents = Array.from(
- new Set(
- (
- source.match(/<((\w+))|minorScale|majorScale|mergeTheme|defaultTheme|(((\w+)Icon))|Position/g) || []
- ).map((component) => component.replace('<', ''))
- )
- ).join(', ')
+ const referencedComponents = getComponentList(source)
- const codeContent = `
-import React from 'react'
-import ReactDOM from 'react-dom'
-import { ${usedComponents} } from 'evergreen-ui'
+ const imports = [
+ "import React from 'react'",
+ "import ReactDOM from 'react-dom'",
+ `import { ${referencedComponents} } from 'evergreen-ui'\n`,
+ ]
-${wrappedSource}
+ const fixtureContent = getFixtures(source)
-ReactDOM.render(
+ const render = `ReactDOM.render(
<${componentName} />,
document.getElementById("root")
)
-`.trim()
+`
+ const codeContent = [...imports, demoComponent, fixtureContent, render]
+ .filter((line: string) => line.trim() !== '')
+ .join('\n')
const html = `
`
@@ -49,7 +43,7 @@ ReactDOM.render(
dependencies: {
react: '16.8.0',
'react-dom': '16.8.0',
- 'evergreen-ui': `${packageJson.dependencies['evergreen-ui']}`,
+ 'evergreen-ui': packageJson.dependencies['evergreen-ui'],
},
devDependencies: {
'react-scripts': 'latest',
@@ -69,3 +63,52 @@ ReactDOM.render(
return `https://codesandbox.io/api/v1/sandboxes/define?parameters=${urlParams}`
}
+
+const compress = (string: string): string =>
+ LZString.compressToBase64(string).replace(/\+/g, `-`).replace(/\//g, `_`).replace(/=+$/, ``)
+
+const getComponentName = (source: string): string =>
+ source.startsWith('function') ? source.substring('function '.length, source.indexOf('(')) : 'Demo'
+
+const getComponentList = (source: string): string =>
+ Array.from(
+ new Set(
+ (
+ source.match(/<((\w+))|toaster|minorScale|majorScale|mergeTheme|defaultTheme|(((\w+)Icon))|Position/g) || []
+ ).map((component: string) => component.replace('<', ''))
+ )
+ ).join(', ')
+
+const getDemoComponent = (source: string): string =>
+ source.startsWith('function')
+ ? source
+ : `
+const Demo = () => {
+ return (
+${indent(source, 4).trimEnd()}
+ )
+}
+`
+
+/**
+ * Returns an expanded string version of referenced fixtures in the source code, based on its name
+ * i.e. `profiles` will be expanded into a variable from the `profiles.json` fixture
+ */
+const getFixtures = (source: string): string => {
+ const fixtureNames = Object.keys(fixtures) as Array
+
+ return fixtureNames
+ .map((fixtureName: keyof typeof fixtures) =>
+ source.includes(fixtureName)
+ ? `const ${fixtureName} = ${JSON.stringify(fixtures[fixtureName], undefined, 2)}`
+ : ''
+ )
+ .join('\n')
+ .trim()
+}
+
+const indent = (source: string, characterLength: number): string =>
+ source
+ .split('\n')
+ .map((line: string) => `${' '.repeat(characterLength)}${line}`)
+ .join('\n')