Skip to content

Commit cb03716

Browse files
committed
v0.3.1 added UnsupportedElement files and fixed Storybook minor version to 8.4
1 parent 60cd5e6 commit cb03716

File tree

5 files changed

+93
-15
lines changed

5 files changed

+93
-15
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
The Bitloops Generator is used by the Bitloops Platform to setup your Bitloops projects.
44

5-
Nonetheless, you can use it independently to setup your next next.js project with TypeScript, Tailwind, Storybook and Cypress all ready to go!
5+
Nonetheless, you can use it independently to setup your next Next.js project with TypeScript, Tailwind, Storybook and Cypress all ready to go!
66

77
## How to run it
88

9-
`npx generator-bitloops setup --project="Your Project Name" --nextjs --typescript --tailwind --storybook --cypress`
9+
`npx -y generator-bitloops setup --project="Your Project Name" --nextjs --typescript --tailwind --storybook --cypress`

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "generator-bitloops",
3-
"version": "0.2.0",
4-
"description": "Bitloops Yeoman generator",
3+
"version": "0.3.1",
4+
"description": "Next.js with TypeScript, Tailwind, Storybook and Cypress generator by Bitloops",
55
"license": "MIT",
66
"author": "Bitloops S.A.",
77
"repository": {
@@ -15,7 +15,7 @@
1515
"files": [
1616
"app",
1717
"setup",
18-
"cli.js"
18+
"cli.mjs"
1919
],
2020
"keywords": [
2121
"bitloops",

setup/index.js

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ export default class extends Generator {
8585
}
8686

8787
this.log("Installing Next.js...");
88-
await new Promise((resolve, error) => {exec(`npx ${createNextAppCommand.join(' ')} && cd ${toKebabCase(this.options.project)} && npm install next@14 react@18 react-dom@18`).on('exit', (code) => {
88+
const additionalPackages = 'react-tooltip';
89+
const patchPackages = `next@14 react@18 react-dom@18 ${additionalPackages}`;
90+
await new Promise((resolve, error) => {exec(`npx ${createNextAppCommand.join(' ')} && cd ${toKebabCase(this.options.project)} && npm install ${patchPackages}`).on('exit', (code) => {
8991
this.destinationRoot(this.destinationPath(toKebabCase(this.options.project)));
9092
resolve();
9193
});});
@@ -95,10 +97,11 @@ export default class extends Generator {
9597
// Conditionally initialize Storybook
9698
if (this.options.storybook) {
9799
this.log("Adding Storybook...");
98-
this.spawnCommandSync('npx', ['-y', 'storybook@latest', 'init', '--no-dev']);
99-
if (this.options.tailwind) {
100-
this.spawnCommandSync('npx', ['storybook@latest', 'add', '@storybook/addon-styling-webpack']);
101-
}
100+
this.spawnCommandSync('npx', ['-y', 'storybook@7.4', 'init', '--no-dev']);
101+
// if (this.options.tailwind) {
102+
// Tailwind CSS specific setup if needed
103+
// this.spawnCommandSync('npx', ['storybook@latest', 'add', '@storybook/addon-styling-webpack']);
104+
// }
102105
}
103106
}
104107

@@ -115,14 +118,17 @@ export default class extends Generator {
115118
if (this.options.typescript) {
116119
this.log('Replace Next.js\' TypeScript configuration file with JS...');
117120
// Remove TypeScript configuration files given they require Next.js 15
118-
fs.unlinkSync(this.destinationPath('next.config.ts'));
119-
console.log('Template Path:', this.templatePath('next.config.js'));
120-
console.log('Destination Path:', this.destinationPath('next.config.js'));
121+
try {
122+
fs.unlinkSync(this.destinationPath('next.config.ts'));
123+
this.log(`Deleted next.config.ts`);
124+
} catch (err) {
125+
console.error('Error deleting next.config.ts:', err);
126+
}
121127
this.fs.copyTpl(
122128
this.templatePath('next.config.js'),
123129
this.destinationPath('next.config.js'),
124-
);
125-
this.log(`Deleted next.config.ts and created next.config.js instead`);
130+
);
131+
this.log(`Created next.config.js instead`);
126132
}
127133
}
128134

@@ -178,6 +184,18 @@ export default class extends Generator {
178184
this.templatePath('globals.css'),
179185
this.destinationPath('src/app/globals.css'),
180186
);
187+
188+
this.log('Adding Bitloops support components...');
189+
this.fs.copyTpl(
190+
this.templatePath('src.components.bitloops.Unsupported.tsx'),
191+
this.destinationPath('src/components/bitloops/Unsupported.tsx'),
192+
);
193+
if (this.options.storybook) {
194+
this.fs.copyTpl(
195+
this.templatePath('src.components.bitloops.Unsupported.stories.tsx'),
196+
this.destinationPath('src/components/bitloops/Unsupported.stories.tsx'),
197+
);
198+
}
181199
}
182200
}
183201

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { Meta, StoryObj } from '@storybook/react';
2+
import { UnsupportedElement, UnsupportedElementProps } from './Unsupported';
3+
4+
const meta: Meta<typeof UnsupportedElement> = {
5+
title: 'Bitloops/Unsupported',
6+
component: UnsupportedElement,
7+
parameters: {
8+
layout: 'centered',
9+
},
10+
tags: ['autodocs'],
11+
};
12+
13+
export default meta;
14+
15+
const props: UnsupportedElementProps = {
16+
type: 'VECTOR',
17+
elementClassName: 'w-128 h-32',
18+
};
19+
20+
type Story = StoryObj<typeof UnsupportedElement>;
21+
22+
export const Default: Story = {
23+
args: props,
24+
parameters: {
25+
layout: 'fullscreen',
26+
},
27+
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { Tooltip } from 'react-tooltip';
2+
import 'react-tooltip/dist/react-tooltip.css';
3+
4+
type UnsupportedType =
5+
| 'VECTOR'
6+
| 'GROUP'
7+
| 'STAR'
8+
| 'ELLIPSE'
9+
| 'LINE'
10+
| 'REGULAR_POLYGON'
11+
| 'SLICE'
12+
| 'IMAGE';
13+
14+
export type UnsupportedElementProps = {
15+
type: UnsupportedType;
16+
elementClassName: string;
17+
};
18+
export function UnsupportedElement(props: UnsupportedElementProps) {
19+
const { type, elementClassName } = props;
20+
return (
21+
<div
22+
className={`${elementClassName} relative group border border-red-500 border-dashed`}
23+
data-tooltip-id='tooltip'
24+
data-tooltip-content={`Unsupported: ${type}`}
25+
>
26+
<Tooltip
27+
id='tooltip'
28+
place='top'
29+
className='bg-black text-white p-2 rounded-[4px] text-xs whitespace-nowrap'
30+
/>
31+
</div>
32+
);
33+
}

0 commit comments

Comments
 (0)