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

feat(Provider): set scrollbar styles #1223

Merged
merged 6 commits into from
Apr 16, 2019
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Export `call-missed-line` icon in Teams theme @96andrei ([#1203](https://github.com/stardust-ui/react/pull/1203))
- Add `pointing` prop to `Popup` ([#1198](https://github.com/stardust-ui/react/pull/1198))
- [Teams Theme] Export missing read-aloud icon in Teams Theme @joheredi ([#1225](https://github.com/stardust-ui/react/pull/1225))
- Add styles for scrollbar to `ProviderBox` in Teams Theme ([#1223](https://github.com/stardust-ui/react/pull/1223))

<!--------------------------------[ v0.27.0 ]------------------------------- -->
## [v0.27.0](https://github.com/stardust-ui/react/tree/v0.27.0) (2019-04-10)
Expand Down
22 changes: 0 additions & 22 deletions docs/src/components/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,28 +133,6 @@ class Sidebar extends React.Component<any, any> {
left: 0,
padding: 0,
maxHeight: '100vh',

'::-webkit-scrollbar': {
'-webkit-appearance': 'none',
height: '10px',
width: '10px',
},
'::-webkit-scrollbar-track': {
background: 'rgba(255, 255, 255, 0.1)',
borderRadius: 0,
},
'::-webkit-scrollbar-thumb': {
cursor: 'pointer',
borderRadius: '5px',
background: 'rgba(255, 255, 255, 0.25)',
transition: 'color 0.2s ease',
},
'::-webkit-scrollbar-thumb:window-inactive': {
background: 'rgba(255, 255, 255, 0.15)',
},
'::-webkit-scrollbar-thumb:hover': {
background: 'rgba(255, 255, 255, 0.35)',
},
}

const menuSectionStyles: ICSSInJSStyle = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Image } from '@stardust-ui/react'
import * as React from 'react'

const ProviderExampleScrollbar = () => (
<div style={{ height: '100px', overflow: 'scroll' }}>
<Image src="public/images/leaves/4.png" />
</div>
)

export default ProviderExampleScrollbar
21 changes: 14 additions & 7 deletions docs/src/examples/components/Provider/Types/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import * as React from 'react'

import ComponentExample from 'docs/src/components/ComponentDoc/ComponentExample'
import ExampleSection from 'docs/src/components/ComponentDoc/ExampleSection'
import NonPublicSection from 'docs/src/components/ComponentDoc/NonPublicSection'

const Types = () => (
<ExampleSection title="Types">
<ComponentExample
title="Theme"
description="A Provider defines the theme for your components."
examplePath="components/Provider/Types/ProviderExample"
/>
</ExampleSection>
<>
<ExampleSection title="Types">
<ComponentExample
title="Theme"
description="A Provider defines the theme for your components."
examplePath="components/Provider/Types/ProviderExample"
/>
</ExampleSection>
<NonPublicSection title="Types for visual tests">
<ComponentExample examplePath="components/Provider/Types/ProviderExampleScrollbar" />
</NonPublicSection>
</>
)

export default Types
5 changes: 2 additions & 3 deletions packages/react/src/lib/handleRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ const handleRef = <N>(ref: React.Ref<N>, node: N) => {
}

if (ref !== null && typeof ref === 'object') {
// @ts-ignore The `current` property is defined as readonly, however it's a valid way because
// `ref` is a mutable object
ref.current = node
// The `current` property is defined as readonly, however it's a valid way because `ref` is a mutable object
;(ref as React.MutableRefObject<N>).current = node
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the ; cruft?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope and this is sad: prettier/prettier#4630 😭

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, just to mention I hate this, especially that we are not using ; at all... Sad day for me :D

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even worse with the provided example, it is used in our guides... :\

}
}

Expand Down
2 changes: 2 additions & 0 deletions packages/react/src/themes/teams/componentStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ export { default as MenuDivider } from './components/Menu/menuDividerStyles'
export { default as Popup } from './components/Popup/popupStyles'
export { default as PopupContent } from './components/Popup/popupContentStyles'

export { default as ProviderBox } from './components/Provider/providerBoxStyles'

export { default as RadioGroupItem } from './components/RadioGroup/radioGroupItemStyles'

export { default as Segment } from './components/Segment/segmentStyles'
Expand Down
2 changes: 2 additions & 0 deletions packages/react/src/themes/teams/componentVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export { default as MenuDivider } from './components/Menu/menuDividerVariables'
export { default as Popup } from './components/Popup/popupVariables'
export { default as PopupContent } from './components/Popup/popupContentVariables'

export { default as ProviderBox } from './components/Provider/providerBoxVariables'

export { default as RadioGroupItem } from './components/RadioGroup/radioGroupItemVariables'

export { default as Reaction } from './components/Reaction/reactionVariables'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { ComponentStyleFunctionParam, ICSSInJSStyle } from '../../../types'
import { ProviderBoxVariables } from './providerBoxVariables'

export default {
root: ({
variables: v,
}: ComponentStyleFunctionParam<never, ProviderBoxVariables>): ICSSInJSStyle => ({
'& ::-webkit-scrollbar': {
height: v.scrollbarHeight,
width: v.scrollbarWidth,

':disabled': {
display: 'none',
},
},
'& ::-webkit-scrollbar-thumb': {
borderRadius: v.scrollbarThumbBorderRadius,
border: `solid ${v.scrollbarThumbBorderSize} transparent`,
backgroundClip: 'content-box',
backgroundColor: v.scrollbarThumbBackgroundColor,

':hover': {
backgroundColor: v.scrollbarThumbHoverBackgroundColor,
border: `solid ${v.scrollbarThumbHoverBorderSize} transparent`,
},
},
'& ::-webkit-scrollbar-track': {
background: 'transparent',
},
}),
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { pxToRem } from '../../../../lib'
import { ProviderBoxVariables as BaseProviderBoxVariables } from '../../../base/components/Provider/providerBoxVariables'

export interface ProviderBoxVariables extends BaseProviderBoxVariables {
scrollbarHeight: string
scrollbarWidth: string

scrollbarThumbBackgroundColor: string
scrollbarThumbBorderRadius: string
scrollbarThumbBorderSize: string

scrollbarThumbHoverBackgroundColor: string
scrollbarThumbHoverBorderSize: string
}

export default (siteVariables): Partial<ProviderBoxVariables> => ({
scrollbarHeight: pxToRem(16),
scrollbarWidth: pxToRem(16),

scrollbarThumbBackgroundColor: siteVariables.gray06,
scrollbarThumbBorderRadius: pxToRem(9),
scrollbarThumbBorderSize: pxToRem(4),

scrollbarThumbHoverBackgroundColor: siteVariables.gray04,
scrollbarThumbHoverBorderSize: pxToRem(2),
})