Skip to content

Commit

Permalink
fix: linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nmerget committed Jan 9, 2025
1 parent 8e25a54 commit d55ea15
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 59 deletions.
3 changes: 2 additions & 1 deletion packages/foundations/scripts/local/generate-icon-font.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import generateIconFonts from '@db-ui/gif/dist/generate-icon-fonts';
import { generateIconTypes } from './generate-icon-types';
import { generateIconTypes } from './generate-icon-types.js';

const defaultBuildDir = './assets/icons';

const fontName = 'db-ux';

const run = async () => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
await generateIconFonts({
fontName,
src: defaultBuildDir,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

import { writeFileSync } from 'node:fs';
import { ALL_ICONS } from '../public';
import { ALL_ICONS } from '../public.js';

const generateIconOverview = () => {
try {
Expand Down
87 changes: 44 additions & 43 deletions packages/foundations/scripts/local/generate-icon-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,54 @@
* This script can be used to update the icon type for all components using icons.
*/

import { writeFileSync, readFileSync } from "node:fs";
import { writeFileSync, readFileSync } from 'node:fs';

export type GenerateIconTypesProps = {
fontJsonPath: string;
outDir: string;
fontJsonPath: string;
outDir: string;
};

export const generateIconTypes = ({
fontJsonPath,
outDir,
fontJsonPath,
outDir
}: GenerateIconTypesProps) => {
try {
const allIcons: Record<string, string[]> = JSON.parse(
readFileSync(fontJsonPath, "utf8")
);

const icons = Object.keys(allIcons);

const generatedDisclaimer = "/* This file was generated */\n";
const iconTypes = `${generatedDisclaimer}export type IconTypes = string |\n ${icons
.map((icon) => `"${icon}"`)
.join("|\n")};`;
const allIconsFile = `${generatedDisclaimer}export const ALL_ICONS: string[] = ${JSON.stringify(
icons
)};`;

const filesToWrite = [
{
name: "icon-types",
content: iconTypes,
},
{
name: "all-icons",
content: allIconsFile,
},
];

for (const { name, content } of filesToWrite) {
writeFileSync(`${outDir}/${name}.ts`, content);
}

let indexContent = filesToWrite
.map(({ name }) => `export * from "./${name}";`)
.join("\n");

writeFileSync(`${outDir}/index.ts`, indexContent);
} catch (e) {
console.error(e);
}
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const allIcons: Record<string, string[]> = JSON.parse(
readFileSync(fontJsonPath, 'utf8')
);

const icons = Object.keys(allIcons);

const generatedDisclaimer = '/* This file was generated */\n';
const iconTypes = `${generatedDisclaimer}export type IconTypes = string |\n ${icons
.map((icon) => `"${icon}"`)
.join('|\n')};`;
const allIconsFile = `${generatedDisclaimer}export const ALL_ICONS: string[] = ${JSON.stringify(
icons
)};`;

const filesToWrite = [
{
name: 'icon-types',
content: iconTypes
},
{
name: 'all-icons',
content: allIconsFile
}
];

for (const { name, content } of filesToWrite) {
writeFileSync(`${outDir}/${name}.ts`, content);
}

const indexContent = filesToWrite
.map(({ name }) => `export * from "./${name}";`)
.join('\n');

writeFileSync(`${outDir}/index.ts`, indexContent);
} catch (error) {
console.error(error);
}
};
10 changes: 8 additions & 2 deletions showcases/next-showcase/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,16 @@ const App = ({ Component, pageProps }: AppProps) => {
}
secondaryAction={
<>
<DBButton icon="x_placeholder" variant="ghost" noText>
<DBButton
icon="x_placeholder"
variant="ghost"
noText>
Profile
</DBButton>
<DBButton icon="x_placeholder" variant="ghost" noText>
<DBButton
icon="x_placeholder"
variant="ghost"
noText>
Notification
</DBButton>
<DBButton
Expand Down
10 changes: 8 additions & 2 deletions showcases/react-showcase/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,16 @@ const App = () => {
}
secondaryAction={
<>
<DBButton icon="x_placeholder" variant="ghost" noText>
<DBButton
icon="x_placeholder"
variant="ghost"
noText>
Profile
</DBButton>
<DBButton icon="x_placeholder" variant="ghost" noText>
<DBButton
icon="x_placeholder"
variant="ghost"
noText>
Notification
</DBButton>
<DBButton
Expand Down
8 changes: 6 additions & 2 deletions showcases/react-showcase/src/components/form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -315,15 +315,19 @@ const FormComponent = () => {

<DBTabs orientation="vertical">
<DBTabList>
<DBTabItem icon="x_placeholder">Airplane Button</DBTabItem>
<DBTabItem icon="x_placeholder">
Airplane Button
</DBTabItem>
<DBTabItem iconAfter="cancel">Cancel Button</DBTabItem>
<DBTabItem iconAfter="cancel">
Long Button Label with a lot of text
</DBTabItem>
<DBTabItem icon="x_placeholder" iconAfter="cancel">
Another Button Label with a lot of text
</DBTabItem>
<DBTabItem icon="x_placeholder" noText={true}></DBTabItem>
<DBTabItem
icon="x_placeholder"
noText={true}></DBTabItem>
</DBTabList>
<DBTabPanel>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
Expand Down
5 changes: 1 addition & 4 deletions showcases/react-showcase/src/components/header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ const getHeader = ({
<DBButton icon="x_placeholder" variant="ghost" noText>
Notification
</DBButton>
<DBButton
icon="x_placeholder"
variant="ghost"
noText>
<DBButton icon="x_placeholder" variant="ghost" noText>
Help
</DBButton>
</>
Expand Down
5 changes: 1 addition & 4 deletions showcases/react-showcase/src/components/page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ const getPage = ({
<DBButton icon="x_placeholder" variant="ghost" noText>
Notification
</DBButton>
<DBButton
icon="x_placeholder"
variant="ghost"
noText>
<DBButton icon="x_placeholder" variant="ghost" noText>
Help
</DBButton>
</>
Expand Down

0 comments on commit d55ea15

Please sign in to comment.