Skip to content

Commit

Permalink
Merge pull request #328 from commitd/sh-theme
Browse files Browse the repository at this point in the history
Fixes issue with ThemeProvider and Badge
  • Loading branch information
stuarthendren authored Nov 18, 2023
2 parents 937fa09 + 2b55598 commit 1f2c098
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .changeset/seven-doors-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@committed/ds': patch
---

Fix to ThemeProvider logic and Badge typeing
5 changes: 1 addition & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ jobs:
- name: Run build
run: |
pnpm run ci
- name: Config npm
run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: create and publish versions
uses: changesets/action@v1
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta'
Expand All @@ -55,3 +51,4 @@ jobs:
publish: pnpm ci:publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
"test": "turbo run test",
"format": "prettier --write '**/{*.js,*.ts,*.tsx,*.json,*.md,*.mdx}'",
"format:check": "prettier -c '**/{*.js,*.ts,*.tsx,*.json,*.md,*.mdx}'",
"changeset": "changeset",
"ci:1": "turbo run format:check build",
"ci:2": "turbo run lint test",
"ci": "pnpm run ci:1 && pnpm install && pnpm ci:2",
"ci:publish": "pnpm run ci:packages && pnpm run ci:storybook",
"ci:packages": "pnpm --filter=\"./presets/**\" --filter=\"./packages/**\" publish -r --publish-branch beta --access public --no-git-checks",
"ci:packages": "pnpm --filter=\"./presets/**\" --filter=\"./packages/**\" publish -r --publish-branch beta --access public",
"ci:storybook": "pnpm --filter @committed/ds-storybook run deploy-storybook --ci",
"ci:version": "pnpm changeset version"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/ds/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@committed/ds",
"version": "1.0.0",
"type": "module",
"main": "src/index.ts",
"types": "src/index.ts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
Expand Down
11 changes: 6 additions & 5 deletions packages/ds/src/components/Badge/Badge.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RecipeVariantProps, cva, styled } from '@committed/ds-ss'
import React, { ComponentProps } from 'react'
import { Assign, Prettify, forwardRefDefine } from '../../utils'
import { Prettify, forwardRefDefine } from '../../utils'

const DEFAULT_TAG = 'span'

Expand Down Expand Up @@ -88,14 +88,15 @@ const badge = cva({

const StyledBadge = styled(DEFAULT_TAG, badge)

type BadgeVariants = Omit<RecipeVariantProps<typeof badge>, 'status'>
type BadgeVariants = RecipeVariantProps<typeof badge>
type BadgeProps = Prettify<
Assign<
ComponentProps<typeof DEFAULT_TAG>,
Omit<
BadgeVariants & {
children: React.ReactNode
content: React.ReactNode
max?: number
}
},
'status'
>
>

Expand Down
12 changes: 7 additions & 5 deletions packages/ds/src/components/ThemeProvider/ThemeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,13 @@ const ControlledThemeProvider: FC<ThemeProviderProps> = ({
)
} else {
const prevTheme = prevThemeRef.current
if (prevTheme) {
document.body.classList.remove(prevTheme)
}
if (theme) {
document.body.classList.add(theme)
if (prevTheme !== theme) {
if (prevTheme) {
document.body.classList.remove(prevTheme)
}
if (theme) {
document.body.classList.add(theme)
}
}
return <>{children}</>
}
Expand Down

0 comments on commit 1f2c098

Please sign in to comment.