-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af1ba7c
commit 3c78a3b
Showing
10 changed files
with
1,713 additions
and
1,621 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,38 @@ | ||
import flatten from 'lodash/flatten' | ||
import reactElementToJSXString from 'react-element-to-jsx-string' | ||
|
||
import capitalize from 'lodash/capitalize' | ||
|
||
import type { Snippet } from './types' | ||
|
||
const req = (require as any).context( | ||
const req = require.context( | ||
'../reference/snippets', | ||
true, | ||
/\.snippets\.tsx$/, | ||
) | ||
|
||
const snippets = flatten( | ||
req.keys().map((filename: string) => { | ||
const matches = filename.match( | ||
/([a-zA-Z-]+)\/([a-zA-Z-]+)\.snippets\.tsx?$/, | ||
) | ||
if (!matches) return [] | ||
const snippets = req.keys().map((filename: string) => { | ||
const matches = filename.match( | ||
/([a-zA-Z-]+)\/([a-zA-Z-]+)\.snippets\.tsx?$/, | ||
) | ||
if (!matches) return [] | ||
|
||
const snippets = req(filename).snippets as Snippet[] | ||
const snippets = req(filename).snippets as Snippet[] | ||
|
||
return snippets.map((snippet) => { | ||
const groupName = capitalize(matches[1]) | ||
const displayName = matches[2] | ||
const code | ||
return snippets.map((snippet) => { | ||
const groupName = capitalize(matches[1]) | ||
const displayName = matches[2] | ||
const code | ||
= typeof snippet.code === 'string' | ||
? snippet.code | ||
: reactElementToJSXString(snippet.code) | ||
|
||
return { | ||
...snippet, | ||
name: groupName, | ||
group: snippet.group || displayName, | ||
code, | ||
} | ||
}) | ||
}), | ||
) | ||
return { | ||
...snippet, | ||
name: groupName, | ||
group: snippet.group || displayName, | ||
code, | ||
} | ||
}) | ||
}).flat() | ||
|
||
export default snippets |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.