Skip to content

Commit

Permalink
feat(provider): Renamed package and added ToastProvider component
Browse files Browse the repository at this point in the history
  • Loading branch information
sullivanpj committed May 14, 2024
1 parent 0763e4c commit daab4ee
Show file tree
Hide file tree
Showing 20 changed files with 451 additions and 99 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { YStack } from "@tamagui/stacks";
import { ThemeProvider } from "@cyclone-ui/theme-provider";
import { ThemeProvider } from "@cyclone-ui/provider";

export const StorybookDecorator = (Story: any, args: any) => {
const { theme: themeKey } = args.globals;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@
"@cyclone-ui/media-queries": "workspace:*",
"@cyclone-ui/nx": "workspace:*",
"@cyclone-ui/pop-up": "workspace:*",
"@cyclone-ui/provider": "workspace:*",
"@cyclone-ui/storybook": "workspace:*",
"@cyclone-ui/theme-provider": "workspace:*",
"@cyclone-ui/themes": "workspace:*",
"@cyclone-ui/website": "workspace:*"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"parserOptions": {
"project": ["packages/theme-provider/tsconfig.*?.json"]
"project": ["packages/provider/tsconfig.*?.json"]
},
"rules": {}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- START header -->
<!-- END header -->

# theme-provider
# provider

A package containing the ThemeProvider component used to manage the applications theme state

Expand All @@ -13,14 +13,14 @@ A package containing the ThemeProvider component used to manage the applications
Using [pnpm](http://pnpm.io):

```bash
pnpm add -D @cyclone-ui/theme-provider
pnpm add -D @cyclone-ui/provider
```

<details>
<summary>Using npm</summary>

```bash
npm install -D @cyclone-ui/theme-provider
npm install -D @cyclone-ui/provider
```

</details>
Expand All @@ -29,7 +29,7 @@ npm install -D @cyclone-ui/theme-provider
<summary>Using yarn</summary>

```bash
yarn add -D @cyclone-ui/theme-provider
yarn add -D @cyclone-ui/provider
```

</details>
Expand All @@ -44,15 +44,15 @@ This project is built using [Nx](https://nx.dev). As a result, many of the usual

### Building

Run `nx build theme-provider` to build the library.
Run `nx build provider` to build the library.

### Running unit tests

Run `nx test theme-provider` to execute the unit tests via [Jest](https://jestjs.io).
Run `nx test provider` to execute the unit tests via [Jest](https://jestjs.io).

### Linting

Run `nx lint theme-provider` to run [ESLint](https://eslint.org/) on the package.
Run `nx lint provider` to run [ESLint](https://eslint.org/) on the package.

<!-- START footer -->
<!-- END footer -->
3 changes: 3 additions & 0 deletions packages/provider/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { getJestConfig } from "@storm-software/testing-tools";

export default getJestConfig("packages/provider", true, "provider");
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "@cyclone-ui/theme-provider",
"name": "@cyclone-ui/provider",
"version": "0.0.1",
"private": false,
"description": "A repository containing the core front-end components used by Storm Software across many platforms",
"repository": {
"type": "github",
"url": "https://github.com/storm-software/cyclone-ui.git",
"directory": "packages/theme-provider"
"directory": "packages/provider"
},
"funding": {
"type": "github",
Expand All @@ -28,6 +28,7 @@
"dependencies": {
"@tamagui/core": "^1.97.1",
"@tamagui/portal": "^1.97.1",
"@tamagui/toast": "^1.97.1",
"@tamagui/web": "^1.97.1",
"zustand": "^4.5.2"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "theme-provider",
"name": "provider",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "library",
"sourceRoot": "packages/theme-provider/src",
"sourceRoot": "packages/provider/src",
"targets": {
"build": {
"cache": true,
Expand All @@ -11,13 +11,13 @@
"dependsOn": ["^build"],
"output": "{options.outputPath}",
"options": {
"outputPath": "dist/packages/theme-provider",
"tsConfig": "packages/theme-provider/tsconfig.json",
"project": "packages/theme-provider/package.json",
"outputPath": "dist/packages/provider",
"tsConfig": "packages/provider/tsconfig.json",
"project": "packages/provider/package.json",
"defaultConfiguration": "production",
"assets": [
{
"input": "packages/theme-provider",
"input": "packages/provider",
"glob": "*.md",
"output": "/"
},
Expand Down
24 changes: 24 additions & 0 deletions packages/provider/src/Provider.server.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { PropsWithChildren } from "react";
import {
ThemeProviderServer,
type ThemeProviderServerProps
} from "./ThemeProvider.server";
import { ToastProvider, type ToastProviderProps } from "./ToastProvider";

export type ProviderServerProps = PropsWithChildren<{
toast: ToastProviderProps;
theme: ThemeProviderServerProps;
}>;

export const ProviderServer = ({
children,
toast,
theme,
...props
}: ProviderServerProps) => {
return (
<ThemeProviderServer {...theme}>
<ToastProvider {...toast}>{children}</ToastProvider>
</ThemeProviderServer>
);
};
21 changes: 21 additions & 0 deletions packages/provider/src/Provider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { PropsWithChildren } from "react";
import { ToastProvider, type ToastProviderProps } from "./ToastProvider";
import { ThemeProvider, type ThemeProviderProps } from "./ThemeProvider";

export type ProviderProps = PropsWithChildren<{
toast: ToastProviderProps;
theme: ThemeProviderProps;
}>;

export const Provider = ({
children,
toast,
theme,
...props
}: ProviderProps) => {
return (
<ThemeProvider {...theme}>
<ToastProvider {...toast}>{children}</ToastProvider>
</ThemeProvider>
);
};
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { TamaguiProvider, type TamaguiProviderProps } from "@tamagui/web";
import { config } from "@cyclone-ui/config";
import { PropsWithChildren } from "react";

export type ThemeProviderServerProps = Partial<TamaguiProviderProps> &
Omit<TamaguiProviderProps, "config">;
export type ThemeProviderServerProps = PropsWithChildren<
Partial<TamaguiProviderProps> &
Omit<TamaguiProviderProps, "defaultTheme" | "config">
>;

export const ThemeProviderServer = ({
children,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ import { useThemeNameState } from "./theme-state";
import { TamaguiProvider, type TamaguiProviderProps } from "@tamagui/web";
import { config } from "@cyclone-ui/config";
import { PortalProvider } from "@tamagui/portal";
import { PropsWithChildren } from "react";

declare const window: any;

export type ThemeProviderProps = Partial<TamaguiProviderProps> &
Omit<TamaguiProviderProps, "defaultTheme" | "config">;
export type ThemeProviderProps = PropsWithChildren<
Partial<TamaguiProviderProps> &
Omit<TamaguiProviderProps, "defaultTheme" | "config">
>;

export const ThemeProvider = ({ children, ...props }: ThemeProviderProps) => {
let theme = props?.defaultTheme;
Expand Down
17 changes: 17 additions & 0 deletions packages/provider/src/ToastProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {
ToastProvider as TamaguiToastProvider,
type ToastProviderProps as TamaguiToastProviderProps
} from "@tamagui/toast";
import { PropsWithChildren } from "react";

export type ToastProviderProps = PropsWithChildren<
Partial<TamaguiToastProviderProps> & Omit<TamaguiToastProviderProps, "id">
>;

export const ToastProvider = ({ children, ...props }: ToastProviderProps) => {
return (
<TamaguiToastProvider id="Storm Software" {...props}>
{children}
</TamaguiToastProvider>
);
};
15 changes: 15 additions & 0 deletions packages/provider/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* The provider library used by Storm Software for building TypeScript applications.
*
* @remarks
* A package containing the Provider component used to manage the applications theme state
*
* @packageDocumentation
*/

export * from "./ThemeProvider";
export * from "./ThemeProvider.server";
export * from "./theme-state";
export * from "./ToastProvider";
export * from "./Provider";
export * from "./Provider.server";
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"jsx": "react-jsx"
Expand Down
File renamed without changes.
3 changes: 0 additions & 3 deletions packages/theme-provider/jest.config.ts

This file was deleted.

12 changes: 0 additions & 12 deletions packages/theme-provider/src/index.ts

This file was deleted.

Loading

0 comments on commit daab4ee

Please sign in to comment.