This repository was archived by the owner on Sep 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 139
feat(types): improve & add type declarations #473
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2bb4540
feat(types): improve & add type declarations
Pwuts f5a400d
Merge branch 'develop' into improve-types
codebender828 a5b01d3
Merge branch 'develop' into improve-types
codebender828 b9eb1bf
Merge branch 'develop' into improve-types
codebender828 1e37eb9
Merge branch 'develop' into improve-types
codebender828 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
interface ChakraToastOptions { | ||
position?: 'bottom' | 'top' | 'right' | 'left' | ||
duration?: number | ||
render?: (options: { onClose?: VoidFunction, id: any }) => any | ||
title?: string | ||
description?: string | ||
status?: 'info' | 'warning' | 'success' | 'error' | ||
variant?: 'solid' | 'subtle' | 'top-accent' | 'left-accent' | ||
isClosable?: boolean | ||
} | ||
|
||
function useToast(): (options: ChakraToastOptions) => void | ||
|
||
export default useToast |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import CToast from './CToast' | ||
export default CToast |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,24 @@ | ||
import { PluginObject } from "vue" | ||
import { IconPack } from "@fortawesome/fontawesome-common-types" | ||
import { Theme } from "../../chakra-ui-theme/types" | ||
|
||
export type Theme = { | ||
breakpoints: any | ||
zIndices: any | ||
radii: any | ||
opacity: any | ||
borders: any | ||
colors: any | ||
borderWidths: any | ||
sizes: any | ||
shadows: any | ||
space: any | ||
fontSizes: any | ||
fonts: any | ||
fontWeights: any | ||
lineHeights: any | ||
letterSpacings: any | ||
export type Icon = { | ||
path: string | ||
viewBox?: string | ||
attrs?: any | ||
} | ||
|
||
export type Options = { | ||
theme: Theme | ||
extendTheme: Theme | ||
icons: { | ||
extend: any | ||
extend: { [name: string]: Icon } | ||
iconPack: string | ||
iconSet: any | ||
iconSet: IconPack | ||
} | ||
} | ||
|
||
export type Chakra = PluginObject<Options> | ||
export type ChakraPlugin = PluginObject<Options> | ||
|
||
declare let chakra: Chakra | ||
export default chakra | ||
declare let chakra: ChakraPlugin | ||
export default chakra |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,16 @@ | ||
import Chakra from "./chakra" | ||
import Chakra, { Icon } from "./chakra" | ||
import { Theme } from "../../chakra-ui-theme/types" | ||
import useToast from "../src/CToast" | ||
|
||
declare module 'vue/types/vue' { | ||
interface Vue { | ||
$toast: ReturnType<typeof useToast> | ||
$chakra: { | ||
theme: Theme | ||
icons: { [name: string]: Icon } | ||
} | ||
} | ||
} | ||
|
||
export * from './component' | ||
export default Chakra | ||
export default Chakra |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import Chakra, { Icon } from "./chakra" | ||
import { Theme } from "../../chakra-ui-theme/types" | ||
import useToast from "../src/CToast" | ||
|
||
declare module '@nuxt/types' { | ||
interface Context { | ||
$toast?: ReturnType<typeof useToast> | ||
$chakra: { | ||
theme: Theme | ||
icons: { [name: string]: Icon } | ||
} | ||
} | ||
|
||
interface NuxtAppOptions { | ||
$toast?: ReturnType<typeof useToast> | ||
$chakra: { | ||
theme: Theme | ||
icons: { [name: string]: Icon } | ||
} | ||
} | ||
} | ||
|
||
declare module 'vue/types/vue' { | ||
interface Vue { | ||
$toast: ReturnType<typeof useToast> | ||
$chakra: { | ||
theme: Theme | ||
icons: { [name: string]: Icon } | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export type Theme = { | ||
breakpoints: { [key: string]: string } | ||
zIndices: { [key: string]: string | number } | ||
radii: { [key: string]: string } | ||
opacity: { [key: string]: string } | ||
borders: { [key: string]: string } | ||
colors: { [key: string]: string | { [opacity: string]: string }} | ||
fonts: { | ||
heading: string | ||
body: string | ||
mono: string | ||
} | ||
fontSizes: { [key: string]: string } | ||
fontWeights: { [key: string]: number } | ||
letterSpacings: { [key: string]: string } | ||
lineHeights: { [key: string]: string } | ||
borderWidths: { [key: string]: string } | ||
shadows: { [key: string]: string } | ||
sizes: { [key: string]: string } | ||
space: { [key: string]: string } | ||
} | ||
|
||
declare const theme: Theme | ||
Comment on lines
+1
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey @Pwuts Is it possible that we can derive a deep Partial from the original theme object here? Something like: import theme from './src`
export type Theme = DeepPartial<typeof theme> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the definition of Theme shouldn't be partial, but it could be derived from the default theme, sure. |
||
|
||
export default theme |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.