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

0.7.x #96

Merged
merged 13 commits into from
Jan 3, 2024
19 changes: 12 additions & 7 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import type { Preview, StoryContext, StoryFn } from '@storybook/react';
import type { ReactElement } from 'react';

import { MantineProvider } from '@mantine/core';

import { Provider, themes } from '@smile/react-front-kit-shared';

function withProvider(Story: StoryFn, context: StoryContext): ReactElement {
return (
<Provider
colorScheme={context.globals.colorScheme as 'dark' | 'light'}
theme={
themes[context.globals.theme as 'main' | 'primary' | 'secondary'].theme
}
>
<Story />
<Provider>
<MantineProvider
theme={{
...themes[context.globals.theme as 'main' | 'primary' | 'secondary']
.theme,
colorScheme: context.globals.colorScheme as 'dark' | 'light',
}}
>
<Story />
</MantineProvider>
</Provider>
);
}
Expand Down
6 changes: 2 additions & 4 deletions apps/next/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ReactElement, ReactNode } from 'react';

import { Provider, mainTheme } from '@smile/react-front-kit';
import { Provider } from '@smile/react-front-kit-shared';
import { Open_Sans } from 'next/font/google';

const openSans = Open_Sans({
Expand All @@ -18,9 +18,7 @@ export default function RootLayout(props: IRootLayoutProps): ReactElement {
return (
<html className={openSans.variable} lang="en">
<body>
<Provider colorScheme="light" theme={mainTheme}>
{children}
</Provider>
<Provider>{children}</Provider>
</body>
</html>
);
Expand Down
3 changes: 2 additions & 1 deletion apps/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"@smile/react-front-kit": "*",
"@smile/react-front-kit-shared": "*",
"storybook-pages": "*"
},
"devDependencies": {
Expand All @@ -28,6 +29,6 @@
"typescript": "~5.2.0"
},
"lint-staged": {
"*.{js,jsx,ts,tsx}": "eslint --max-warnings=0 --ignore-path ../../.gitignore"
"*.{js,jsx,ts,tsx}": "eslint --ignore-path ../../.gitignore"
}
}
21 changes: 11 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
"build:app": "turbo run build:app",
"dev": "turbo run dev",
"lint": "turbo run lint && npm run lint:root",
"lint:root": "DEBUG=eslint:cli-engine eslint --max-warnings=0 --ignore-path <(cat .gitignore .eslintignore) . && tsc --noEmit",
"lint:fix": "DEBUG=eslint:cli-engine eslint --fix --max-warnings=0 --ignore-path <(cat .gitignore .eslintignore) . && tsc --noEmit",
"lint:root": "DEBUG=eslint:cli-engine eslint --ignore-path <(cat .gitignore .eslintignore) . && tsc --noEmit",
"lint:fix": "DEBUG=eslint:cli-engine eslint --fix --ignore-path <(cat .gitignore .eslintignore) . && tsc --noEmit",
"test": "turbo run test",
"format": "prettier --write --ignore-unknown --ignore-path .prettierignore --ignore-path .gitignore .",
"generate": "turbo gen react-component",
"changeset": "changeset",
"version": "turbo run build lint test && changeset version",
"publish": "turbo run build lint test && changeset publish",
Expand Down Expand Up @@ -88,6 +89,6 @@
},
"lint-staged": {
"*": "prettier --write --ignore-unknown --ignore-path <(cat .gitignore .prettierignore)",
"*.{js,jsx,ts,tsx}": "eslint --max-warnings=0 --ignore-path <(cat .gitignore .eslintignore)"
"*.{js,jsx,ts,tsx}": "eslint --ignore-path <(cat .gitignore .eslintignore)"
}
}
12 changes: 12 additions & 0 deletions packages/react-front-kit-dropzone/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# @smile/react-front-kit-dropzone

## 0.7.0

### Minor Changes

- [#87](https://github.com/Smile-SA/react-front-kit/pull/87) [`dbc06ca`](https://github.com/Smile-SA/react-front-kit/commit/dbc06ca55961b69663ab7fdc02609c6525ae361d) Thanks [@tonai](https://github.com/tonai)! - Add theme provider and update barrel file for better next.js compatibility

### Patch Changes

- Updated dependencies [[`dbc06ca`](https://github.com/Smile-SA/react-front-kit/commit/dbc06ca55961b69663ab7fdc02609c6525ae361d), [`7415d9b`](https://github.com/Smile-SA/react-front-kit/commit/7415d9b9d119abfc850dda2ab6fa94845e72aee6), [`5696400`](https://github.com/Smile-SA/react-front-kit/commit/5696400e6f703da52db5f7199b50f8251fa76726), [`eede698`](https://github.com/Smile-SA/react-front-kit/commit/eede698ce172e20eb1de4c70e3d59b7510afb9df), [`480af11`](https://github.com/Smile-SA/react-front-kit/commit/480af1122b41e28d938bd665c1aa998272c99d9a), [`70b674f`](https://github.com/Smile-SA/react-front-kit/commit/70b674f3513b4bf996e8f83a46c8a132ca3712ac)]:
- @smile/[email protected]
- @smile/[email protected]

## 0.6.0

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions packages/react-front-kit-dropzone/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@smile/react-front-kit-dropzone",
"version": "0.6.0",
"version": "0.7.0",
"description": "Dropzone React component library based on mantine",
"license": "MIT",
"homepage": "https://github.com/Smile-SA/react-front-kit",
Expand Down Expand Up @@ -47,8 +47,8 @@
"prepublishOnly": "npm run build && node ../../scripts/prepublish.mjs"
},
"dependencies": {
"@smile/react-front-kit": "0.6.0",
"@smile/react-front-kit-shared": "0.6.0"
"@smile/react-front-kit": "0.7.0",
"@smile/react-front-kit-shared": "0.7.0"
},
"devDependencies": {
"@babel/preset-env": "^7.22.20",
Expand Down
7 changes: 6 additions & 1 deletion packages/react-front-kit-dropzone/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
/* eslint-disable react-refresh/only-export-components */
export * from './Components/Dropzone/Dropzone';

'use client';

// component exports
export { Dropzone } from './Components/Dropzone/Dropzone';
export type { IDropzoneProps, IFile } from './Components/Dropzone/Dropzone';
12 changes: 12 additions & 0 deletions packages/react-front-kit-shared/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# @smile/react-front-kit-shared

## 0.7.0

### Minor Changes

- [#87](https://github.com/Smile-SA/react-front-kit/pull/87) [`dbc06ca`](https://github.com/Smile-SA/react-front-kit/commit/dbc06ca55961b69663ab7fdc02609c6525ae361d) Thanks [@tonai](https://github.com/tonai)! - Add theme provider and update barrel file for better next.js compatibility

- [#95](https://github.com/Smile-SA/react-front-kit/pull/95) [`5696400`](https://github.com/Smile-SA/react-front-kit/commit/5696400e6f703da52db5f7199b50f8251fa76726) Thanks [@QuentinLeCaignec](https://github.com/QuentinLeCaignec)! - Added `FilterList` component, renamed `FiltersBar` in `SidebarFilters`
and `FiltersCheckboxList` in `SearchableCheckboxList`,
refactored `SearchableCheckboxList`, added common `IFilter` type in shared
package, added topContent prop to `SwitchableView`, fixed `BrowsingPage` with
name changes.

## 0.6.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/react-front-kit-shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@smile/react-front-kit-shared",
"version": "0.6.0",
"version": "0.7.0",
"description": "Shared elements for react-front-kit component library based on mantine",
"license": "MIT",
"homepage": "https://github.com/Smile-SA/react-front-kit",
Expand Down
28 changes: 16 additions & 12 deletions packages/react-front-kit-shared/src/3-custom/Provider/Provider.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
'use client';

import type { MantineThemeOverride } from '@mantine/core';
import type { IThemeOverride } from '../../types';
import type { ReactElement, ReactNode } from 'react';

import { MantineProvider } from '@mantine/core';

import { mainTheme } from '../../theme';
import { themeContext } from '../../contexts';
import { createThemes } from '../../helpers';

export interface IProviderProps {
export interface IProviderProps extends IThemeOverride {
children?: ReactNode;
colorScheme?: 'dark' | 'light';
theme?: MantineThemeOverride;
}
export function Provider(props: IProviderProps): ReactElement {
const { children, colorScheme = 'light', theme = mainTheme } = props;
const { children, colorScheme = 'light', ...themeConfig } = props;
const themes = createThemes(themeConfig);
const { main } = themes;

return (
<MantineProvider
theme={{ ...theme, colorScheme }}
withGlobalStyles
withNormalizeCSS
>
{children}
</MantineProvider>
<themeContext.Provider value={themes}>
<MantineProvider
theme={{ ...main, colorScheme }}
withGlobalStyles
withNormalizeCSS
>
{children}
</MantineProvider>
</themeContext.Provider>
);
}
1 change: 1 addition & 0 deletions packages/react-front-kit-shared/src/contexts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './theme';
29 changes: 29 additions & 0 deletions packages/react-front-kit-shared/src/contexts/theme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type { IThemes } from '../types';
import type { MantineThemeOverride } from '@mantine/styles';

import { createContext, useContext } from 'react';

export const themeContext = createContext<IThemes>({
main: {},
primary: {},
secondary: {},
});

export function useThemes(): IThemes {
return useContext(themeContext);
}

export function useMainTheme(): MantineThemeOverride {
const { main } = useContext(themeContext);
return main;
}

export function usePrimaryTheme(): MantineThemeOverride {
const { primary } = useContext(themeContext);
return primary;
}

export function useSecondaryTheme(): MantineThemeOverride {
const { secondary } = useContext(themeContext);
return secondary;
}
3 changes: 2 additions & 1 deletion packages/react-front-kit-shared/src/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './utilities';
export * from './theme';
export * from './typeGuard';
export * from './utilities';
Loading