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

Commit ddf7685

Browse files
committed
fix 4
1 parent 8a334fc commit ddf7685

File tree

183 files changed

+933
-815
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

183 files changed

+933
-815
lines changed

docs/src/app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react'
22
import { hot } from 'react-hot-loader/root'
33
import { Provider, Debug, themes } from '@fluentui/react'
44

5-
import { mergeThemes } from '@fluentui/react/src/utils'
5+
import { mergeThemes } from '@fluentui/styles'
66
import { ThemeContext, ThemeContextData, themeContextDefaults } from './context/ThemeContext'
77
import Routes from './routes'
88
import { PerfDataProvider } from './components/ComponentDoc/PerfChart'

docs/src/components/ComponentBestPractices.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as React from 'react'
22
import * as _ from 'lodash'
33
import {
4+
Extendable,
45
Box,
56
Flex,
67
Header,
@@ -10,7 +11,6 @@ import {
1011
Segment,
1112
ShorthandCollection,
1213
} from '@fluentui/react'
13-
import { Extendable } from 'src/types'
1414

1515
export type ComponentBestPracticesProps = Extendable<{
1616
doList?: ShorthandCollection<ListItemProps>

docs/src/components/ComponentDoc/BehaviorCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react'
2-
import { Divider, Segment, Text } from '@fluentui/react'
2+
import { Divider, ICSSInJSStyle, Segment, Text } from '@fluentui/react'
33
import * as _ from 'lodash'
44
import ComponentExampleTitle from './ComponentExample/ComponentExampleTitle'
55
import BehaviorDescription from './BehaviorDescription'
@@ -10,7 +10,7 @@ export const behaviorVariantDisplayName = (fileName: string) => {
1010
return _.upperFirst(_.lowerCase(divided))
1111
}
1212

13-
export const exampleStyle: React.CSSProperties = {
13+
export const exampleStyle: ICSSInJSStyle = {
1414
boxShadow: '0 1px 2px rgba(0, 0, 0, 0.2)',
1515
}
1616

docs/src/components/ComponentDoc/BehaviorDescription.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react'
2-
import { Loader } from '@fluentui/react/src'
2+
import { Loader } from '@fluentui/react'
33

44
const AccessibilityDescription = React.lazy(() => import('./InlineMarkdown'))
55

docs/src/components/ComponentDoc/ComponentExample/ComponentExample.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@ import {
55
KnobProvider,
66
LogInspector,
77
} from '@fluentui/docs-components'
8-
import { Flex, ICSSInJSStyle, Menu, Provider, Segment } from '@fluentui/react'
8+
import {
9+
ComponentVariablesInput,
10+
Flex,
11+
ICSSInJSStyle,
12+
Menu,
13+
Provider,
14+
Segment,
15+
ThemeInput,
16+
} from '@fluentui/react'
917
import * as _ from 'lodash'
1018
import * as React from 'react'
1119
import { RouteComponentProps, withRouter } from 'react-router-dom'
@@ -23,7 +31,6 @@ import ComponentExampleTitle from './ComponentExampleTitle'
2331
import ComponentSourceManager, {
2432
ComponentSourceManagerRenderProps,
2533
} from '../ComponentSourceManager'
26-
import { ThemeInput } from 'packages/react/src/themes/types'
2734
import VariableResolver from 'docs/src/components/VariableResolver/VariableResolver'
2835
import ComponentExampleVariables from 'docs/src/components/ComponentDoc/ComponentExample/ComponentExampleVariables'
2936

@@ -43,7 +50,7 @@ export interface ComponentExampleProps
4350

4451
interface ComponentExampleState {
4552
anchorName: string
46-
componentVariables: Object
53+
componentVariables: ComponentVariablesInput
4754
isActive: boolean
4855
isActiveHash: boolean
4956
usedVariables: Record<string, string[]>
@@ -53,7 +60,7 @@ interface ComponentExampleState {
5360
showVariables: boolean
5461
}
5562

56-
const childrenStyle: React.CSSProperties = {
63+
const childrenStyle: ICSSInJSStyle = {
5764
paddingTop: 0,
5865
paddingBottom: '10px',
5966
}

docs/src/components/ComponentDoc/ComponentExample/ComponentExampleVariables.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import * as React from 'react'
1212
import { ThemeContext } from 'react-fela'
1313

1414
import ComponentExampleVariable, { ComponentExampleVariableProps } from './ComponentExampleVariable'
15-
import { mergeThemeVariables } from '@fluentui/react/src/utils/mergeThemes'
15+
import { mergeThemeVariables } from '@fluentui/styles'
1616

1717
type ComponentExampleVariablesProps = {
1818
onChange: ComponentExampleVariableProps['onChange']

docs/src/components/ComponentDoc/ComponentProp/ComponentPropExtra.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react'
2-
import { Extendable } from 'src/types'
2+
import { Extendable } from '@fluentui/react'
33

44
export interface ComponentPropExtraProps {
55
children?: JSX.Element[]

docs/src/components/ComponentDoc/ComponentProps/ComponentPropCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as React from 'react'
22
import ComponentTableProps from '../ComponentPropsTable'
3-
import { Divider, Segment } from '@fluentui/react/src'
3+
import { Divider, ICSSInJSStyle, Segment } from '@fluentui/react'
44

5-
export const cardStyle: React.CSSProperties = {
5+
export const cardStyle: ICSSInJSStyle = {
66
boxShadow: '0 1px 2px rgba(0, 0, 0, 0.2)',
77
}
88

docs/src/components/ComponentDoc/ContributionPrompt.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as PropTypes from 'prop-types'
22
import * as React from 'react'
3-
4-
import { Icon, Segment, Text, ICSSInJSStyle } from '@fluentui/react'
3+
import { ICSSInJSStyle } from '@fluentui/styles'
4+
import { Icon, Segment, Text } from '@fluentui/react'
55
import { constants } from '@fluentui/react/src/utils'
66

77
const wrapStyle: ICSSInJSStyle = { wordBreak: 'break-word' }

docs/src/components/ComponentDoc/ExampleSection.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import * as React from 'react'
2-
import { Grid, Header } from '@fluentui/react'
2+
import { Grid, Extendable, Header, ICSSInJSStyle } from '@fluentui/react'
33

4-
import { Extendable } from 'src/types'
5-
6-
const headerStyle: React.CSSProperties = {
4+
const headerStyle: ICSSInJSStyle = {
75
marginTop: '1.5em',
86
marginBottom: '0.5em',
97
color: '#999',

docs/src/components/DocsBehaviorRoot.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as _ from 'lodash'
22
import * as PropTypes from 'prop-types'
33
import * as React from 'react'
4-
import { Header, Segment, Divider } from '@fluentui/react'
4+
import { Header, Segment, Divider, ICSSInJSStyle } from '@fluentui/react'
55
import DocumentTitle from 'react-document-title'
66
import ComponentExampleTitle from './ComponentDoc/ComponentExample/ComponentExampleTitle'
77
import BehaviorDescription from './ComponentDoc/BehaviorDescription'
@@ -24,7 +24,7 @@ class DocsBehaviorRoot extends React.Component<any, any> {
2424
}
2525

2626
render() {
27-
const exampleStyle: React.CSSProperties = {
27+
const exampleStyle: ICSSInJSStyle = {
2828
boxShadow: '0 1px 2px rgba(0, 0, 0, 0.2)',
2929
}
3030

docs/src/components/DocsLayout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { withRouter } from 'react-router-dom'
66

77
import Sidebar from 'docs/src/components/Sidebar/Sidebar'
88
import { scrollToAnchor } from 'docs/src/utils'
9-
import { mergeThemes } from '@fluentui/react/src/utils'
9+
import { mergeThemes } from '@fluentui/styles'
1010

1111
const anchors = new AnchorJS({
1212
class: 'anchor-link',

docs/src/examples/components/Slider/commonScreenerSteps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Slider } from '@fluentui/react/src'
1+
import { Slider } from '@fluentui/react'
22

33
const selectors = {
44
input: `.${Slider.slotClassNames.input}`,

docs/src/examples/components/Status/Types/StatusExample.shorthand.tsx

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,20 @@ import { compose } from '@fluentui/react-bindings'
33
import * as React from 'react'
44
import * as PropTypes from 'prop-types'
55

6-
const MyStatus = compose<{ title: never; disabled?: boolean; name: string }>(Status, {
7-
displayName: 'MyStatus',
8-
mapPropsToBehavior: props => {
9-
return {
10-
name: props.name,
11-
}
12-
},
13-
mapPropsToStyles: props => ({
14-
disabled: props.disabled,
15-
}),
16-
// Existing
17-
// handledProps: ['disabled']
18-
// Emotion approach
19-
shouldForwardProp: prop => prop === 'disabled',
20-
overrideStyles: true,
21-
})
6+
// const MyStatus = compose<{ title: never; disabled?: boolean; name: string }>(Status, {
7+
// displayName: 'MyStatus',
8+
// mapPropsToBehavior: props => ({
9+
// name: props.name,
10+
// }),
11+
// mapPropsToStyles: props => ({
12+
// disabled: props.disabled,
13+
// }),
14+
// // Existing
15+
// // handledProps: ['disabled']
16+
// // Emotion approach
17+
// shouldForwardProp: propName => propName === 'disabled',
18+
// overrideStyles: true,
19+
// })
2220

2321
const StatusWithProp = compose<{ square?: boolean }>(Status, {
2422
displayName: 'SquareStatus',
@@ -45,11 +43,11 @@ const StatusExampleShorthand = () => (
4543
<h2>
4644
Composed <code>MyStatus</code>
4745
</h2>
48-
<MyStatus
46+
{/* <MyStatus
4947
accessibility={props => ({ attributes: { root: { 'data-shift': props.name } } })}
5048
name="Hoba!"
5149
/>
52-
<MyStatus disabled />
50+
<MyStatus disabled /> */}
5351
</>
5452
)
5553

docs/src/prototypes/Prototypes.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import * as React from 'react'
2-
import { Box, Header, Segment } from '@fluentui/react'
2+
import { Box, Header, ICSSInJSStyle, Segment } from '@fluentui/react'
33

44
interface PrototypeSectionProps {
55
title?: React.ReactNode
6-
styles?: React.CSSProperties
6+
styles?: ICSSInJSStyle
77
}
88

99
interface ComponentPrototypeProps extends PrototypeSectionProps {

docs/src/prototypes/chatPane/composeMessage.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
MenuItemProps,
99
ShorthandCollection,
1010
IconXSpacing,
11+
ICSSInJSStyle,
1112
} from '@fluentui/react'
1213

1314
import { Props } from 'src/types'
@@ -52,7 +53,7 @@ const ComposeMessage: React.FunctionComponent<ComposeMessageProps> = props => (
5253
/>
5354
)
5455

55-
const getInputWrapperStyles = ({ attached }: ComposeMessageProps): React.CSSProperties => {
56+
const getInputWrapperStyles = ({ attached }: ComposeMessageProps): ICSSInJSStyle => {
5657
const borderTopRadius = '3px'
5758
const borderBottomRadius = '2px'
5859
const borderWidth = '1px'

docs/src/prototypes/chatPane/services/messageFactoryMock.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
Attachment,
3+
Extendable,
34
Popup,
45
Menu,
56
AvatarProps,
@@ -10,7 +11,7 @@ import {
1011
import * as React from 'react'
1112
import * as _ from 'lodash'
1213
import * as keyboardKey from 'keyboard-key'
13-
import { Extendable, ShorthandValue } from 'src/types'
14+
import { ShorthandValue } from 'src/types'
1415
import { ChatData, UserStatus, MessageData, UserData, areSameDay, getFriendlyDateString } from '.'
1516

1617
export enum ChatItemTypes {

docs/src/prototypes/employeeCard/AvatarEmployeeCard.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as React from 'react'
2-
import { Avatar, Popup } from '@fluentui/react'
2+
import { Avatar, Extendable, Popup } from '@fluentui/react'
33
import EmployeeCard, { EmployeeCardProps } from './EmployeeCard'
4-
import { Extendable } from 'src/types'
54

65
export interface AvatarEmployeeCardState {
76
popupOpen: boolean

docs/src/prototypes/employeeCard/EmployeeCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react'
2-
import { Extendable, ShorthandValue } from 'src/types'
3-
import { Avatar, AvatarProps, Divider, Grid } from '@fluentui/react'
2+
import { ShorthandValue } from 'src/types'
3+
import { Avatar, AvatarProps, Divider, Extendable, Grid } from '@fluentui/react'
44
import CustomText from './CustomText'
55

66
export interface EmployeeCardProps {

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

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,48 @@ import * as React from 'react'
44
import { ThemeContext } from 'react-fela'
55

66
import {
7+
ComponentSlotStylesPrepared,
8+
ComponentStyleFunctionParam,
79
emptyTheme,
810
mergeComponentStyles,
911
mergeComponentVariables,
10-
} from '@fluentui/react/src/utils/mergeThemes'
11-
import {
12-
ComponentSlotStylesPrepared,
13-
ComponentStyleFunctionParam,
14-
ProviderContextPrepared,
15-
} from '@fluentui/react'
16-
import resolveStylesAndClasses from '@fluentui/react/src/utils/resolveStylesAndClasses'
12+
} from '@fluentui/styles'
13+
import { ProviderContextPrepared } from '@fluentui/react'
14+
import resolveStylesAndClasses from '../styles/resolveStylesAndClasses'
1715

18-
const useStyles = (displayName: string | string[], options: any) => {
19-
const className = options.className || 'no-classname-🙉'
20-
const rtl = options.rtl || false
21-
const props = options.mapPropsToStyles()
22-
const { className: userClassName, styles, design, variables } = options.mapInlineToStyles()
16+
type UseStylesOptions<StyleProps> = {
17+
className?: string
18+
mapPropsToStyles?: () => StyleProps
19+
mapPropsToInlineStyles?: () => InlineStyleProps // Consider better name
20+
rtl?: boolean
21+
}
2322

24-
const context: ProviderContextPrepared = React.useContext(ThemeContext)
23+
type InlineStyleProps = {
24+
className?: string
25+
design?: any // TODO type
26+
styles?: any // TODO type
27+
variables?: any // TODO type
28+
}
29+
30+
const useStyles = <StyleProps>(
31+
displayName: string | string[],
32+
options: UseStylesOptions<StyleProps>,
33+
) => {
34+
const {
35+
className = 'no-classname-🙉',
36+
mapPropsToStyles = () => ({} as StyleProps),
37+
mapPropsToInlineStyles = () => ({} as InlineStyleProps),
38+
rtl = false,
39+
} = options
2540

41+
const context: ProviderContextPrepared = React.useContext(ThemeContext)
2642
const { disableAnimations = false, renderer = null, theme = emptyTheme } = context || {}
2743

44+
// TODO: throw if there is no context
45+
46+
const props = mapPropsToStyles()
47+
const { className: userClassName, styles, design, variables } = mapPropsToInlineStyles()
48+
2849
const componentVariables = Array.isArray(displayName)
2950
? displayName.map(displayName => theme.componentVariables[displayName])
3051
: [theme.componentVariables[displayName]]
@@ -37,7 +58,7 @@ const useStyles = (displayName: string | string[], options: any) => {
3758
...componentVariables,
3859
variables,
3960
)(theme.siteVariables)
40-
console.log(componentStyles, props)
61+
4162
// Resolve styles using resolved variables, merge results, allow props.styles to override
4263
const mergedStyles: ComponentSlotStylesPrepared = mergeComponentStyles(
4364
...componentStyles,

packages/react-bindings/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ export { default as useStyles } from './hooks/useStyles'
1414
export { default as unstable_useDispatchEffect } from './hooks/useDispatchEffect'
1515
export { default as useStateManager } from './hooks/useStateManager'
1616

17+
export { default as getStyles } from './styles/getStyles'
18+
1719
export { default as callable } from './utils/callable'
1820
export { default as getElementType } from './utils/getElementType'
1921
export { default as getUnhandledProps } from './utils/getUnhandledProps'

packages/react/src/utils/createAnimationStyles.tsx renamed to packages/react-bindings/src/styles/createAnimationStyles.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { AnimationProp, ThemePrepared } from '../themes/types'
1+
import { AnimationProp } from '@fluentui/react' // TODO FIX ME
2+
import { ThemePrepared } from '@fluentui/styles'
23

34
const createAnimationStyles = (animation: AnimationProp, theme: ThemePrepared) => {
45
let animationCSSProp = {}

0 commit comments

Comments
 (0)