Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Searchbox #2

Merged
merged 20 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
f2e268d
chore: Update dependencies
joerideg Jul 12, 2024
aa0e15c
build: Change generator template to include feature groups again
joerideg Jul 12, 2024
7d3da07
build: Revamp generator
joerideg Jul 12, 2024
faabec8
feat(searchbox): Add `@bloomreach/discovery-web-sdk` dependency
joerideg Jul 17, 2024
492672b
build: Update templates for generator
joerideg Jul 17, 2024
ddca59c
feat(searchbox): Add searchBox component, hook and context utilizing …
joerideg Jul 17, 2024
4225889
perf(searchbox): Memoize onChange handler
joerideg Jul 18, 2024
071a8ba
fix(searchbox): Add default values for the SearchContext
joerideg Jul 18, 2024
5e9a478
docs(searchbox): Add explanatory comments
joerideg Jul 18, 2024
84b38e8
test(searchbox): Generate snapshots for searchbox e2e
joerideg Jul 18, 2024
7787ed6
docs(searchbox): Add indication of default value of debounceDelay
joerideg Jul 18, 2024
eccf223
docs(searchbox): Add description to searchbox component example
joerideg Jul 18, 2024
95f481d
build: Fix import in generator for hook
joerideg Jul 18, 2024
d2469af
feat(searchbox): Add `useSearchBox` hook
joerideg Jul 19, 2024
93d0cc1
feat(searchbox): Support search types: product, category, content, be…
joerideg Jul 19, 2024
8c0b57b
build: Its unneccesary to run on both push and PR
joerideg Jul 19, 2024
1dd491d
build: Ensure the peerDependencies are not included in the build arti…
joerideg Jul 22, 2024
b391fb4
feat(searchbox): Enhance search context and search box functionalities
joerideg Jul 29, 2024
a86def1
build: Let e2e depend on succesfull build
joerideg Jul 29, 2024
eb52bc7
0.0.2
joerideg Jul 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"tsconfigRootDir": "."
},
"rules": {
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/no-explicit-any": "off"
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ run-name: ${{github.workflow}} (${{github.event_name}} on ${{ github.ref_name}})

on:
push:
pull_request:
workflow_dispatch:
inputs:
update-snapshots:
Expand Down Expand Up @@ -75,7 +74,7 @@ jobs:

- name: Upload coverage artifacts
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
if: ${{ success() }}
with:
path: coverage
name: coverage
Expand All @@ -93,7 +92,7 @@ jobs:

- name: Upload build artifacts
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
if: ${{ success() }}
with:
path: dist
name: assets
Expand All @@ -103,6 +102,7 @@ jobs:
e2e:
name: Run end-to-end tests
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -121,6 +121,12 @@ jobs:
cache: 'pnpm'
cache-dependency-path: pnpm-lock.yaml

- name: Download build assets
uses: actions/download-artifact@v4
with:
name: assets
path: dist

- name: Install dependencies
run: pnpm install

Expand Down Expand Up @@ -148,7 +154,7 @@ jobs:

- name: Upload e2e artifacts
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
if: ${{ success() }}
with:
name: playwright-report
path: playwright-report/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {{pascalCase name}}Meta, { Basic as BasicStory, type Story } from './{{ke

const meta: Meta = {
...{{pascalCase name}}Meta,
title: '{{pascalCase name}}/QA',
title: '{{constantCase group}}/{{pascalCase name}}/QA',
decorators: [
(Story) => (
<div className="qa-story" style=\{{ padding: '2em' }}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.lcui-{{kebabCase name}} {
// component styles
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render } from '@testing-library/react';
import { describe, it, expect } from 'vitest';

import {{pascalCase name}} from './{{kebabCase name}}';
import { {{pascalCase name}} } from './{{kebabCase name}}';

describe('{{pascalCase name}}', () => {
it('should render successfully', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Meta, StoryObj } from '@storybook/react';

import {{pascalCase name}} from './{{kebabCase name}}';
import { {{pascalCase name}} } from './{{kebabCase name}}';

const meta: Meta<typeof {{pascalCase name}}> = {
title: '{{kebabCase name}}',
component: {{kebabCase name}},
title: '{{constantCase group}}/{{pascalCase name}}',
component: {{pascalCase name}},
tags: ['autodocs'],
args: {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { test, expect } from '@playwright/test';

test.describe('{{pascalCase name}}', () => {
test.describe('Base', () => {
const storyId = '{{pascalCase name}}-qa--basic';
const storyId = '{{kebabCase group}}-{{pascalCase name}}-qa--basic';

test('should render successfully', async ({ page }) => {
await page.goto(`/iframe.html?id=${storyId}`);
await page.goto(`/iframe.html?path=/story/${storyId}`);

await expect(page.locator('.qa-story')).toHaveScreenshot();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,30 @@ import './{{kebabCase name}}.scss';
* ### Usage
*
* ```tsx
* import { {{pascalCase name}} } from '@bloomreach/limitless-commerce-ui-kit';
* import { {{pascalCase name}} } from '@bloomreach/limitless-ui-react';
*
* export default function MyCustomComponent() {
* return <{{pascalCase name}}>Write an example of component usage</{{pascalCase name}}>;
* }
* ```
*/
const {{pascalCase name}} = forwardRef((
export const {{pascalCase name}} = forwardRef((
props: {{pascalCase name}}Props,
forwardedRef: ForwardedRef<HTMLDivElement> | null,
): ReactElement => {
const {
className,
children,
...rest // Capture any other properties to pass them to the root element, like `aria-*`, `data-*`, etc.
...rest
} = props;

return (
<div
{...rest}
className={cn('lcui-{{kebabCase name}}')}
className={cn('lcui-{{kebabCase name}}', className)}
ref={forwardedRef}
>
{children}
</div>
);
});

{{pascalCase name}}.displayName = '{{pascalCase name}}';

export default {{pascalCase name}};
8 changes: 8 additions & 0 deletions generators/component/{{ kebabCase name }}.types.ts.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { PropsWithChildren } from 'react';

export interface {{pascalCase name}}Props extends PropsWithChildren {
/**
* Custom class name for the container of the component.
*/
className?: string;
}
2 changes: 2 additions & 0 deletions generators/feature/index.ts.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { {{pascalCase name}} } from './{{kebabCase name}}/{{kebabCase name}}';
export type { {{pascalCase name}}Props } from './{{kebabCase name}}/{{kebabCase name}}.types';
16 changes: 16 additions & 0 deletions generators/hook/{{ kebabCase name }}.hook.ts.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* The hook description.
*
* ### Usage
*
* ```tsx
* import { {{pascalCase name}} } from '@bloomreach/limitless-ui-react';
*
* export default function MyCustomComponent() {
* return <{{pascalCase name}}>Write an example of component usage</{{pascalCase name}}>;
* }
* ```
*/
export function use{{ kebabCase name}}() {

}
65 changes: 65 additions & 0 deletions generators/plopfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { readdir } from 'node:fs/promises';

export default function generate(
/** @type {import('plop').NodePlopAPI} */
plop,
) {
plop.setGenerator('feature', {
description: 'Create a new feature folder',
prompts: [
{
type: 'input',
name: 'name',
message: 'Please, enter the feature name:',
validate: (value) => !!value,
},
],
actions: [
{
type: 'add',
path: './src/{{kebabCase name}}/index.ts',
skipIfExists: true,
},
{
type: 'append',
path: './src/index.ts',
template: "export * from './{{kebabCase name}}';\n",
},
],
});

plop.setGenerator('component', {
description: 'Create a new component',
prompts: [
{
type: 'input',
name: 'name',
message: 'Please, enter the component name:',
validate: (value) => !!value,
},
{
type: 'list',
name: 'group',
choices: async () => {
const files = await readdir('./src/', { withFileTypes: true });
return files.filter((f) => f.isDirectory()).map((f) => f.name);
},
message: 'Please, select the feature folder:',
validate: (value) => !!value,
},
],
actions: [
{
type: 'addMany',
destination: './src/{{kebabCase group}}/{{kebabCase name}}',
base: './component/',
templateFiles: './component/*',
},
{
type: 'append',
path: './src/{{kebabCase group}}/index.ts',
templateFile: './feature/index.ts.hbs',
},
],
});
}
67 changes: 34 additions & 33 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bloomreach/limitless-ui-react",
"version": "0.0.1",
"version": "0.0.2",
"repository": {
"type": "git",
"url": "git+https://github.com/bloomreach/limitless-ui-react.git"
Expand All @@ -26,70 +26,71 @@
"test": "vitest --run --coverage.enabled",
"test:watch": "vitest",
"type-check": "tsc --noEmit",
"generate": "plop",
"generate": "plop --plopfile ./generators/plopfile.js --dest .",
"storybook": "storybook dev -p 6006",
"storybook:build": "storybook build",
"e2e": "pnpm storybook:build && playwright test",
"e2e:report": "playwright show-report"
},
"dependencies": {
"peerDependencies": {
"@bloomreach/discovery-web-sdk": "^1.1.0",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@chromatic-com/storybook": "^1.6.0",
"@chromatic-com/storybook": "^1.6.1",
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
"@faker-js/faker": "^8.4.1",
"@playwright/test": "1.42.1",
"@playwright/test": "^1.45.1",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@storybook/addon-a11y": "^8.1.11",
"@storybook/addon-actions": "^8.1.11",
"@storybook/addon-essentials": "^8.1.11",
"@storybook/addon-interactions": "^8.1.11",
"@storybook/addon-links": "^8.1.11",
"@storybook/addon-mdx-gfm": "^8.1.11",
"@storybook/addon-onboarding": "^8.1.11",
"@storybook/addon-storysource": "^8.1.11",
"@storybook/blocks": "^8.1.11",
"@storybook/cli": "^8.1.11",
"@storybook/manager-api": "^8.1.11",
"@storybook/preview-api": "^8.1.11",
"@storybook/react": "^8.1.11",
"@storybook/react-vite": "^8.1.11",
"@storybook/test": "^8.1.11",
"@storybook/theming": "^8.1.11",
"@storybook/addon-a11y": "^8.2.2",
"@storybook/addon-actions": "^8.2.2",
"@storybook/addon-essentials": "^8.2.2",
"@storybook/addon-interactions": "^8.2.2",
"@storybook/addon-links": "^8.2.2",
"@storybook/addon-mdx-gfm": "^8.2.2",
"@storybook/addon-onboarding": "^8.2.2",
"@storybook/addon-storysource": "^8.2.2",
"@storybook/blocks": "^8.2.2",
"@storybook/cli": "^8.2.2",
"@storybook/manager-api": "^8.2.2",
"@storybook/preview-api": "^8.2.2",
"@storybook/react": "^8.2.2",
"@storybook/react-vite": "^8.2.2",
"@storybook/test": "^8.2.2",
"@storybook/theming": "^8.2.2",
"@testing-library/react": "^16.0.0",
"@types/node": "20",
"@types/node": "^20.14.10",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^7.13.1",
"@typescript-eslint/parser": "^7.13.1",
"@typescript-eslint/eslint-plugin": "^7.16.0",
"@typescript-eslint/parser": "^7.16.0",
"@vitejs/plugin-react": "^4.3.1",
"@vitest/coverage-istanbul": "^1.6.0",
"classnames": "^2.5.1",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jsx-a11y": "^6.9.0",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.7",
"eslint-plugin-react-refresh": "^0.4.8",
"eslint-plugin-storybook": "^0.8.0",
"happy-dom": "^14.12.3",
"husky": "^9.0.11",
"plop": "^4.0.1",
"prettier": "^3.2.5",
"sass": "^1.77.6",
"semantic-release": "23.0.8",
"storybook": "^8.1.11",
"prettier": "^3.3.2",
"sass": "^1.77.8",
"semantic-release": "^23.1.1",
"storybook": "^8.2.2",
"typescript": "~5.4.5",
"vite": "^5.2.10",
"vite-plugin-dts": "^3.9.0",
"vitest": "^1.5.3"
"vite": "^5.3.3",
"vite-plugin-dts": "^3.9.1",
"vitest": "^1.6.0"
},
"engines": {
"node": ">=20",
"pnpm": ">=9"
},
"packageManager": "pnpm@9.1.2"
"packageManager": "pnpm@9.5.0+sha512.140036830124618d624a2187b50d04289d5a087f326c9edfc0ccd733d76c4f52c3a313d4fc148794a2a9d81553016004e6742e8cf850670268a7387fc220c903"
}
2 changes: 0 additions & 2 deletions plop-templates/component/index.ts.hbs

This file was deleted.

12 changes: 0 additions & 12 deletions plop-templates/component/{{ dashCase name }}.types.ts.hbs

This file was deleted.

Loading