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

feature(components): adds IntRange type #242

Merged
merged 3 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/happy-kings-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wethegit/components": patch
---

feature: adds IntRange type helper
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"changeset": "changeset",
"release": "turbo run build && changeset publish",
"version": "changeset version",
"prepare": "husky install"
"prepare": "husky prepare"
},
"devDependencies": {
"@changesets/changelog-github": "^0.5.0",
Expand Down
1 change: 1 addition & 0 deletions packages/wethegit-components/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const config: StorybookConfig = {
],
docs: {
defaultName: "Overview",
autodocs: true
},
framework: {
name: getAbsolutePath("@storybook/react-vite"),
Expand Down
33 changes: 16 additions & 17 deletions packages/wethegit-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,26 @@
"typescript": "^5.2.2"
},
"devDependencies": {
"@storybook/addon-essentials": "~8.1.3",
"@storybook/addon-interactions": "~8.1.3",
"@storybook/addon-links": "~8.1.2",
"@storybook/blocks": "~8.1.3",
"@storybook/react": "~8.1.3",
"@storybook/react-vite": "~8.1.4",
"@storybook/test": "~8.1.3",
"@storybook/test-runner": "~0.18.1",
"@storybook/addon-essentials": "^8.1.5",
"@storybook/addon-interactions": "^8.1.5",
"@storybook/addon-links": "^8.1.5",
"@storybook/blocks": "^8.1.5",
"@storybook/react": "^8.1.5",
"@storybook/react-vite": "^8.1.5",
"@storybook/test": "^8.1.5",
"@storybook/test-runner": "^0.18.2",
"@types/react": "^18.2.66",
"@types/react-dom": "^18.2.22",
"@vitejs/plugin-react": "^4.3.0",
"storybook": "~8.1.3",
"storybook": "^8.1.5",
"typescript": "^5.2.2",
"vite": "^5.2.0",
"@storybook/addon-a11y": "^8.1.3",
"@storybook/addon-actions": "^8.1.4",
"@storybook/addon-docs": "^8.1.3",
"@storybook/addon-themes": "^8.1.1",
"@storybook/manager-api": "^8.1.3",
"@storybook/theming": "^8.1.3",
"@storybook/addon-a11y": "^8.1.5",
"@storybook/addon-actions": "^8.1.5",
"@storybook/addon-docs": "^8.1.5",
"@storybook/addon-themes": "^8.1.5",
"@storybook/manager-api": "^8.1.5",
"@storybook/theming": "^8.1.5",
"@wethegit/react-hooks": "^3.0.1",
"@wethegit/react-modal": "^2.0.0",
"eslint": "^8.15.0",
Expand All @@ -74,6 +74,5 @@
},
"publishConfig": {
"access": "public"
},
"dependencies": {}
}
}
7 changes: 7 additions & 0 deletions packages/wethegit-components/src/types/utils.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// recursion for the integer
type Enumerate<N extends number, Acc extends number[] = []> = Acc['length'] extends N
? Acc[number]
: Enumerate<N, [...Acc, Acc['length']]>

// makes sure we exclude the numbers in one range from the other
type IntRange<F extends number, T extends number> = Exclude<Enumerate<T>, Enumerate<F>>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const TOTAL_SPACE_CLASSES = 10
const BREAKPOINTS: Exclude<Breakpoint, "sm">[] = ["md", "lg", "xl", "xxl"]

// This should be the same amount as TOTAL_SPACE_CLASSES
type SpacingRange = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10
type SpacingRange = IntRange<0, 10>

/**
* @description
Expand Down
Loading
Loading