Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit 077f0cb

Browse files
authored
feat(styles): typing improvements (#2312)
* -typing improvements * -typing improvements
1 parent e57e61c commit 077f0cb

File tree

8 files changed

+15
-11
lines changed

8 files changed

+15
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
2828
- Restricted prop set in the `List` & `ListItem` @layershifter ([#2238](https://github.com/microsoft/fluent-ui-react/pull/2238))
2929
- Remove `mountDocument` prop in `Popup` & `MenuButton` components @layershifter ([#2286](https://github.com/microsoft/fluent-ui-react/pull/2286))
3030
- Remove `toRefObject` function @layershifter ([#2287](https://github.com/microsoft/fluent-ui-react/pull/2287))
31+
- Add typing `ComponentSlotStylesResolved`, that replaces the incorrect `ComponentSlotStylesPrepared` in the return value of `useStyles`, `renderComponent`, `createComponent` @mnajdova ([#2312](https://github.com/microsoft/fluent-ui-react/pull/2312))
3132

3233
### Fixes
3334
- Fix styleParam to always be required in the styles functions @layershifter, @mnajdova ([#2235](https://github.com/microsoft/fluent-ui-react/pull/2235))

packages/react-bindings/src/hooks/useStyles.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
22
ComponentSlotStyle,
3-
ComponentSlotStylesPrepared,
3+
ComponentSlotStylesResolved,
44
ComponentVariablesInput,
55
DebugData,
66
emptyTheme,
@@ -27,7 +27,7 @@ type UseStylesOptions<StyleProps extends PrimitiveProps> = {
2727

2828
type UseStylesResult = {
2929
classes: ComponentSlotClasses
30-
styles: ComponentSlotStylesPrepared
30+
styles: ComponentSlotStylesResolved
3131
}
3232

3333
type InlineStyleProps<StyleProps> = {

packages/react-bindings/src/styles/getStyles.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
callable,
33
ComponentSlotStylesInput,
44
ComponentSlotStylesPrepared,
5+
ComponentSlotStylesResolved,
56
ComponentStyleFunctionParam,
67
ComponentVariablesObject,
78
DebugData,
@@ -37,7 +38,7 @@ type GetStylesOptions = StylesContextValue<{
3738
export type GetStylesResult = {
3839
classes: ComponentSlotClasses
3940
variables: ComponentVariablesObject
40-
styles: ComponentSlotStylesPrepared
41+
styles: ComponentSlotStylesResolved
4142
theme: StylesContextValue['theme']
4243
}
4344

packages/react/src/components/Chat/ChatItem.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
} from '../../utils'
1919
import Box, { BoxProps } from '../Box/Box'
2020

21-
import { ComponentSlotStylesPrepared } from '@fluentui/styles'
21+
import { ComponentSlotStylesResolved } from '@fluentui/styles'
2222
import ChatMessage from './ChatMessage'
2323

2424
export interface ChatItemSlotClassNames {
@@ -86,7 +86,7 @@ class ChatItem extends UIComponent<WithAsProp<ChatItemProps>, any> {
8686
)
8787
}
8888

89-
renderChatItem(styles: ComponentSlotStylesPrepared) {
89+
renderChatItem(styles: ComponentSlotStylesResolved) {
9090
const { gutter, contentPosition } = this.props
9191
const gutterElement =
9292
gutter &&

packages/react/src/components/Chat/ChatMessage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import { MenuItemProps } from '../Menu/MenuItem'
4040
import Text, { TextProps } from '../Text/Text'
4141
import Reaction, { ReactionProps } from '../Reaction/Reaction'
4242
import { ReactionGroupProps } from '../Reaction/ReactionGroup'
43-
import { ComponentSlotStylesPrepared } from '@fluentui/styles'
43+
import { ComponentSlotStylesResolved } from '@fluentui/styles'
4444

4545
export interface ChatMessageSlotClassNames {
4646
actionMenu: string
@@ -212,7 +212,7 @@ class ChatMessage extends UIComponent<WithAsProp<ChatMessageProps>, ChatMessageS
212212

213213
renderActionMenu(
214214
actionMenu: ChatMessageProps['actionMenu'],
215-
styles: ComponentSlotStylesPrepared,
215+
styles: ComponentSlotStylesResolved,
216216
) {
217217
const { unstable_overflow: overflow, positionActionMenu } = this.props
218218
const { messageNode } = this.state

packages/react/src/utils/createComponent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
ReactAccessibilityBehavior,
44
AccessibilityActionHandlers,
55
} from '@fluentui/react-bindings'
6-
import { ComponentSlotStylesPrepared } from '@fluentui/styles'
6+
import { ComponentSlotStylesResolved } from '@fluentui/styles'
77
import * as _ from 'lodash'
88
import * as React from 'react'
99

@@ -14,7 +14,7 @@ export interface CreateComponentRenderConfig {
1414
accessibility: ReactAccessibilityBehavior
1515
classes: ComponentSlotClasses
1616
rtl: boolean
17-
styles: ComponentSlotStylesPrepared
17+
styles: ComponentSlotStylesResolved
1818
}
1919

2020
export interface CreateComponentConfig<P> {

packages/react/src/utils/renderComponent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from '@fluentui/react-bindings'
1212
import {
1313
emptyTheme,
14-
ComponentSlotStylesPrepared,
14+
ComponentSlotStylesResolved,
1515
ComponentVariablesObject,
1616
DebugData,
1717
PropsWithVarsAndStyles,
@@ -28,7 +28,7 @@ export interface RenderResultConfig<P> {
2828
classes: ComponentSlotClasses
2929
unhandledProps: Props
3030
variables: ComponentVariablesObject
31-
styles: ComponentSlotStylesPrepared
31+
styles: ComponentSlotStylesResolved
3232
accessibility: ReactAccessibilityBehavior
3333
rtl: boolean
3434
theme: ThemePrepared

packages/styles/src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ export interface ComponentSlotStylesInput<TProps = {}, TVars = {}>
188188
export interface ComponentSlotStylesPrepared<TProps = {}, TVars = {}>
189189
extends Record<string, ComponentSlotStyleFunction<TProps, TVars>> {}
190190

191+
export interface ComponentSlotStylesResolved extends Record<string, ICSSInJSStyle> {}
192+
191193
export interface ComponentStyleFunctionParam<
192194
TProps extends PropsWithVarsAndStyles = PropsWithVarsAndStyles,
193195
TVars extends ComponentVariablesObject = ComponentVariablesObject

0 commit comments

Comments
 (0)