-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docs): create get started icons documentation (#188)
- Loading branch information
1 parent
f9ff461
commit 436b9f7
Showing
17 changed files
with
265 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<style> | ||
.icon-gallery > summary { | ||
border-bottom: 1px solid #0002; | ||
cursor: pointer; | ||
font-family: 'Nunito Sans', sans-serif; | ||
font-size: 18px; | ||
font-weight: 600; | ||
margin-bottom: 16px; | ||
user-select: none; | ||
} | ||
</style> |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Meta, Title, IconGallery, IconItem } from '@storybook/blocks' | ||
|
||
import { iconsList } from '../utils/icons-list' | ||
|
||
<Meta title="Getting Started/Icons" /> | ||
|
||
# Icons | ||
|
||
The icons are a collection of icons that can be used in your components. It is based on the [Material Design Icons](https://materialdesignicons.com/) library but we can also add our own custom icons. | ||
|
||
- [Architecture decisions](#architecture-decisions) | ||
- [Using icons](/docs/components-icon--docs) | ||
- [How add a custom icon](https://github.com/juntossomosmais/atomium/tree/main/packages/icons#adding-a-new-icon) | ||
|
||
## List of icons | ||
|
||
See the list of all available icons: | ||
|
||
<details class="icon-gallery"> | ||
<summary>Custom Icons</summary> | ||
<IconGallery> | ||
{iconsList?.custom?.map((icon) => ( | ||
<IconItem name={icon}> | ||
<atom-icon icon={icon}></atom-icon> | ||
</IconItem> | ||
))} | ||
</IconGallery> | ||
</details> | ||
|
||
<details class="icon-gallery"> | ||
<summary>Material Design Icons</summary> | ||
<IconGallery> | ||
{iconsList?.mdi?.map((icon) => ( | ||
<IconItem name={icon}> | ||
<atom-icon icon={icon}></atom-icon> | ||
</IconItem> | ||
))} | ||
</IconGallery> | ||
</details> |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// @note: this export statement is placed here because Nx does not track imports inside .mdx files used for stories. | ||
export * from '@juntossomosmais/atomium-icons' |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module.exports = { | ||
testEnvironment: 'node', | ||
transform: { | ||
'^.+\\.tsx?$': 'ts-jest', | ||
}, | ||
testMatch: ['**/*.spec.ts'], | ||
moduleFileExtensions: ['ts', 'js'], | ||
collectCoverage: true, | ||
coverageReporters: ['lcov'], | ||
coveragePathIgnorePatterns: ['/node_modules/'], | ||
collectCoverageFrom: ['scripts/*.ts', '!scripts/*.spec.ts'], | ||
} |
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,14 +1,31 @@ | ||
{ | ||
"name": "@juntossomosmais/atomium-icons", | ||
"private": true, | ||
"type": "module", | ||
"types": "dist/index.d.ts", | ||
"main": "dist/index.js", | ||
"files": [ | ||
"dist/" | ||
], | ||
"scripts": { | ||
"build": "tsc && node dist/scripts/build.js && npm run generate:types", | ||
"generate:types": "node dist/scripts/generate-types.js && npm run copy", | ||
"copy": "npx copyfiles --flat ./dist/icons.d.ts ../core/src" | ||
"compile": "tsc", | ||
"build": "npx nx exec -- node dist/scripts/build.js", | ||
"generate:types": "npx nx exec -- node dist/scripts/generate-types.js && npm run compile && npm run copy", | ||
"copy": "npx copyfiles --flat ./dist/icons.d.ts ../core/src", | ||
"test:ci": "jest --coverage --no-cache --updateSnapshot --ci", | ||
"test": "jest --maxWorkers=50%" | ||
}, | ||
"nx": { | ||
"targets": { | ||
"build": { | ||
"dependsOn": [ | ||
"compile" | ||
] | ||
}, | ||
"generate:types": { | ||
"dependsOn": [ | ||
"compile" | ||
] | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import fs from 'fs' | ||
import path from 'path' | ||
import { | ||
readSvgDirectories, | ||
writeListFile, | ||
writeSvgFile, | ||
writeTypeDefinitionFile, | ||
} from './helpers' | ||
|
||
const MOCK_SVG_DIR = path.resolve(__dirname, './__mocks__/svg') | ||
|
||
describe('readSvgDirectories', () => { | ||
it('should return an array of all SVG files in the specified directory', () => { | ||
const svgFiles = readSvgDirectories(MOCK_SVG_DIR) | ||
expect(svgFiles).toHaveLength(2) | ||
expect(svgFiles).toContain(path.join(MOCK_SVG_DIR, 'custom/icon.svg')) | ||
expect(svgFiles).toContain(path.join(MOCK_SVG_DIR, 'mdi/icon.svg')) | ||
}) | ||
}) | ||
|
||
describe('writeSvgFile', () => { | ||
it('should mock the fs.writeFileSync function', () => { | ||
jest.mock('fs') | ||
const mockWriteFileSync = jest.fn() | ||
fs.writeFileSync = mockWriteFileSync | ||
|
||
const fileName = 'test.svg' | ||
const content = '<svg viewBox="0 0 100 100"></svg>' | ||
const outputDirectory = './dist' | ||
|
||
writeSvgFile(fileName, content, outputDirectory) | ||
|
||
expect(mockWriteFileSync).toHaveBeenCalledWith( | ||
path.join(outputDirectory, fileName), | ||
content, | ||
'utf-8' | ||
) | ||
}) | ||
}) | ||
|
||
describe('writeTypeDefinitionFile', () => { | ||
it('should write the type definition file for the specified SVG files', () => { | ||
jest.mock('fs') | ||
const mockWriteFileSync = jest.fn() | ||
fs.writeFileSync = mockWriteFileSync | ||
|
||
const svgFiles = ['./svg/custom/customIcon.svg', './svg/mdi/mdiIcon.svg'] | ||
const outputPath = './' | ||
const output = `export type IconProps = ${[ | ||
`'customIcon'`, | ||
`'mdiIcon'`, | ||
].join('\n | ')};` | ||
|
||
writeTypeDefinitionFile(svgFiles, outputPath) | ||
|
||
expect(mockWriteFileSync).toHaveBeenCalledWith('../icons.d.ts', output) | ||
}) | ||
}) | ||
|
||
describe('writeListFile', () => { | ||
it('should mock the fs.writeFileSync function', () => { | ||
jest.mock('fs') | ||
const mockWriteFileSync = jest.fn() | ||
fs.writeFileSync = mockWriteFileSync | ||
|
||
const svgFiles = ['./svg/custom/icon.svg', './svg/mdi/icon.svg'] | ||
const outputPath = './' | ||
const list = { | ||
custom: ['icon'], | ||
mdi: ['icon'], | ||
} | ||
const output = [ | ||
'// THIS FILE IS GENERATED AUTOMATICALLY DO NOT EDIT MANUALLY\n\n', | ||
`export const iconsList = ${JSON.stringify(list, null, 2)}`, | ||
] | ||
|
||
writeListFile(svgFiles, outputPath) | ||
|
||
expect(mockWriteFileSync).toHaveBeenCalledWith( | ||
path.join(outputPath, '../..', 'index.ts'), | ||
output.join('') | ||
) | ||
}) | ||
}) |
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