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

Commit 16b9fd0

Browse files
bcalverycodepretty
authored andcommitted
fix(attachment): themeing and redline (#1033)
* updates to Attachment Styles * more refinement to attachment * making action icon color match text color * updating Changelog entry for PR * fix file capitalization issue * fix accident put changelog entry in wrong place * updating attachment styles * updating icon in the attachment examples and making it show filled state on hover * updating color for attachment dark theme border and backgroundColor * updating changelog
1 parent 9d746c7 commit 16b9fd0

File tree

13 files changed

+160
-19
lines changed

13 files changed

+160
-19
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
2929
- Fix click triggering logic of `Space` and `Enter` keys for `MenuItem` @kuzhelov ([#1175](https://github.com/stardust-ui/react/pull/1175))
3030
- Truncate `content` and `header` of `ListItem` when used from `DropdownSelectedItem` @silviuavram ([#1161](https://github.com/stardust-ui/react/pull/1161))
3131
- Fix `rotate` prop on `Icon` not working in `rtl` @mnajdova ([#1179](https://github.com/stardust-ui/react/pull/1179))
32+
- Updated themeing for `Attachment` for Teams, Teams Dark and Teams Contrast @bcalvery ([#1033]https://github.com/stardust-ui/react/pull/1033)
3233
- `FocusTrapZone` - Do not propagate any keyboard events @sophieH29 ([#1180](https://github.com/stardust-ui/react/pull/1180))
3334
- Capture effect of `Esc` key down event within component for `Popup` and `Dropdown` @kuzhelov ([#1183](https://github.com/stardust-ui/react/pull/1183))
3435

docs/src/examples/components/Attachment/Slots/AttachmentActionExample.shorthand.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,23 @@ class AttachmentActionExampleShorthand extends React.Component {
99
<div>
1010
<Attachment
1111
header="Picture.jpg"
12-
action={{ icon: 'x', onClick: this.handleClick('Remove') }}
12+
action={{
13+
icon: {
14+
name: 'close',
15+
outline: true,
16+
},
17+
onClick: this.handleClick('Remove'),
18+
}}
1319
/>
1420
<Attachment
1521
header="Document.docx"
16-
action={{ icon: 'ellipsis horizontal', onClick: this.handleClick('Show more') }}
22+
action={{
23+
icon: {
24+
name: 'more',
25+
outline: true,
26+
},
27+
onClick: this.handleClick('Show more'),
28+
}}
1729
/>
1830
</div>
1931
)

docs/src/examples/components/Attachment/Types/AttachmentProgressExample.shorthand.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ import { Attachment } from '@stardust-ui/react'
44
const AttachmentProgressExampleShorthand = () => (
55
<Attachment
66
header="Photo.jpg"
7-
action={{ icon: 'x', onClick: () => alert("'X' is clicked!") }}
7+
action={{
8+
icon: {
9+
name: 'close',
10+
outline: true,
11+
},
12+
onClick: () => alert("'X' is clicked!"),
13+
}}
814
progress={33}
915
/>
1016
)

docs/src/examples/components/Attachment/Variations/AttachmentActionableExample.shorthand.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,27 @@ import * as React from 'react'
22
import { Attachment } from '@stardust-ui/react'
33

44
class AttachmentActionableExampleShorthand extends React.Component {
5-
handleClick = () => alert('Attachment was clicked')
5+
handleClick = message => e => {
6+
alert(`'${message}' was clicked`)
7+
e.stopPropagation()
8+
}
69

710
render() {
811
return (
912
<Attachment
1013
actionable
11-
icon="file word outline"
14+
icon="table"
1215
header="Document.docx"
1316
description="800 Kb"
14-
action={{ icon: 'x' }}
17+
action={{
18+
icon: {
19+
name: 'more',
20+
outline: true,
21+
},
22+
onClick: this.handleClick('More Action'),
23+
}}
1524
progress={33}
16-
onClick={this.handleClick}
25+
onClick={this.handleClick('Attachment')}
1726
/>
1827
)
1928
}

packages/react/src/themes/teams-dark/componentVariables.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export { default as Attachment } from './components/Attachment/attachmentVariables'
12
export { default as Button } from './components/Button/buttonVariables'
23
export { default as Chat } from './components/Chat/chatVariables'
34
export { default as ChatMessage } from './components/Chat/chatMessageVariables'
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { AttachmentVariables } from '../../../teams/components/Attachment/attachmentVariables'
2+
3+
export default (siteVariables: any): Partial<AttachmentVariables> => ({
4+
textColor: siteVariables.colors.grey[50],
5+
textColorHover: siteVariables.colors.grey[50],
6+
7+
backgroundColor: siteVariables.gray600,
8+
borderColor: siteVariables.gray850,
9+
boxShadow: siteVariables.shadowLevel1,
10+
})

packages/react/src/themes/teams-dark/siteVariables.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export const gray08 = '#484644' // light theme gray02
1313
export const gray09 = '#3b3a39' // no mapping color
1414
export const gray10 = '#323130' // no mapping color
1515
export const gray14 = '#292828' // no mapping color
16+
export const gray850 = '#1b1a1a'
17+
export const gray600 = '#323131'
1618

1719
export const brand = '#6264A7' // light theme brand - primary[500]
1820
export const brand02 = '#e2e2f6' // light theme brand14 - primary[100]
@@ -30,6 +32,11 @@ export const red = '#d74654' // no mapping color
3032
export const red08 = '#4f232b' // no mapping color
3133
export const green04 = naturalColors.lightGreen[900]
3234

35+
//
36+
// SHADOW LEVELS
37+
//
38+
export const shadowLevel1 = '0 .2rem .4rem -.075rem rgba(0, 0, 0, .25)'
39+
3340
//
3441
// SEMANTIC ASSIGNMENTS
3542
//
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
export { default as Attachment } from './components/Attachment/attachmentStyles'
12
export { default as MenuItem } from './components/Menu/menuItemStyles'

packages/react/src/themes/teams-high-contrast/componentVariables.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export { default as Attachment } from './components/Attachment/attachmentVariables'
12
export { default as Avatar } from './components/Avatar/avatarVariables'
23
export { default as Button } from './components/Button/buttonVariables'
34
export { default as Chat } from './components/Chat/chatVariables'
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { ComponentSlotStylesInput, ICSSInJSStyle } from '../../../types'
2+
import { AttachmentProps } from '../../../../components/Attachment/Attachment'
3+
import { AttachmentVariables } from '../../../teams/components/Attachment/attachmentVariables'
4+
import Button from '../../../../components/Button/Button'
5+
import Icon from '../../../../components/Icon/Icon'
6+
7+
const attachmentStyles: ComponentSlotStylesInput<AttachmentProps, AttachmentVariables> = {
8+
root: ({ props: p, variables: v }): ICSSInJSStyle => ({
9+
...((p.actionable || p.onClick) && {
10+
...(p.isFromKeyboard && {
11+
':focus': {
12+
backgroundColor: v.backgroundColorHover,
13+
color: v.textColorHover,
14+
15+
[`& .${Button.className}`]: {
16+
color: v.textColorHover,
17+
},
18+
19+
[`& .${Icon.className}`]: {
20+
color: v.textColorHover,
21+
},
22+
},
23+
}),
24+
25+
':hover': {
26+
[`& .${Button.className}`]: {
27+
color: v.textColorHover,
28+
},
29+
30+
[`& .${Icon.className}`]: {
31+
color: v.textColorHover,
32+
},
33+
},
34+
}),
35+
}),
36+
37+
action: ({ variables: v }): ICSSInJSStyle => ({
38+
':hover': {
39+
outline: `1px solid ${v.textColorHover}`,
40+
},
41+
}),
42+
}
43+
44+
export default attachmentStyles
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { AttachmentVariables } from '../../../teams/components/Attachment/attachmentVariables'
2+
3+
export default (siteVariables: any): Partial<AttachmentVariables> => ({
4+
borderColor: siteVariables.colors.white,
5+
backgroundColor: siteVariables.colors.black,
6+
backgroundColorHover: siteVariables.accessibleYellow,
7+
textColor: siteVariables.colors.white,
8+
textColorHover: siteVariables.colors.black,
9+
boxShadow: undefined,
10+
progressColor: siteVariables.accessibleGreen,
11+
progressHeight: 6,
12+
})

packages/react/src/themes/teams/components/Attachment/attachmentStyles.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,38 @@ import { ComponentSlotStylesInput, ICSSInJSStyle } from '../../../types'
22
import { AttachmentProps } from '../../../../components/Attachment/Attachment'
33
import { AttachmentVariables } from './attachmentVariables'
44
import { pxToRem } from '../../../../lib'
5+
import Icon from '../../../../components/Icon/Icon'
6+
import { teamsIconClassNames } from '../Icon/svg'
57

68
const attachmentStyles: ComponentSlotStylesInput<AttachmentProps, AttachmentVariables> = {
79
root: ({ props: p, variables: v }): ICSSInJSStyle => ({
810
position: 'relative',
911
display: 'inline-flex',
1012
alignItems: 'center',
11-
width: pxToRem(300),
13+
width: '100%',
14+
maxWidth: pxToRem(440),
1215
minHeight: pxToRem(48),
1316
padding: v.padding,
1417
marginBottom: pxToRem(2),
1518
marginRight: pxToRem(2),
1619
background: v.backgroundColor,
1720
color: v.textColor,
21+
boxShadow: v.boxShadow,
22+
border: `${pxToRem(1)} solid ${v.borderColor}`,
23+
borderRadius: v.borderRadius,
1824

1925
outline: 0,
2026

27+
// todo: remove when #1057 to make box-sizing global is checked in
28+
boxSizing: 'border-box',
29+
'& *': {
30+
boxSizing: `border-box`,
31+
},
32+
2133
...(p.isFromKeyboard && {
2234
':focus': {
23-
outline: `.2rem solid ${v.focusOutlineColor}`,
35+
borderColor: v.focusInnerBorderColor,
36+
boxShadow: `0 0 0 ${pxToRem(1)} ${v.focusOuterBorderColor}`,
2437
},
2538
}),
2639

@@ -29,6 +42,7 @@ const attachmentStyles: ComponentSlotStylesInput<AttachmentProps, AttachmentVari
2942

3043
':hover': {
3144
background: v.backgroundColorHover,
45+
color: v.textColorHover,
3246
},
3347
}),
3448
}),
@@ -56,8 +70,22 @@ const attachmentStyles: ComponentSlotStylesInput<AttachmentProps, AttachmentVari
5670
marginRight: v.iconSpace,
5771
}),
5872

59-
action: (): ICSSInJSStyle => ({
73+
action: ({ variables: v }): ICSSInJSStyle => ({
6074
flex: '0 0 auto',
75+
76+
[`& .${Icon.className}`]: {
77+
color: v.textColor, // this breaks the color change on hover
78+
},
79+
80+
':hover': {
81+
[`& .${teamsIconClassNames.filled}`]: {
82+
display: 'block',
83+
},
84+
85+
[`& .${teamsIconClassNames.outline}`]: {
86+
display: 'none',
87+
},
88+
},
6189
}),
6290

6391
progress: ({ props: p, variables: v }): ICSSInJSStyle => ({
Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import { pxToRem } from '../../../../lib'
22

33
export type AttachmentVariables = {
4-
padding: number
5-
iconSpace: number
4+
padding: string
5+
iconSpace: string
66

7+
borderColor: string
8+
borderRadius: string
79
backgroundColor: string
810
backgroundColorHover: string
911
textColor: string
12+
textColorHover: string
13+
boxShadow: string
1014

1115
progressColor: string
1216
progressHeight: number
@@ -19,27 +23,32 @@ export type AttachmentVariables = {
1923
descriptionFontWeight: number
2024
descriptionLineHeight: number
2125

22-
focusOutlineColor: string
26+
focusInnerBorderColor: string
27+
focusOuterBorderColor: string
2328
}
2429

25-
export default siteVariables => ({
26-
padding: pxToRem(8),
30+
export default (siteVariables: any): AttachmentVariables => ({
31+
padding: `${pxToRem(7)} ${pxToRem(3)} ${pxToRem(7)} ${pxToRem(11)}`, // padding set to 1px less to account for 1px border
2732
iconSpace: pxToRem(12),
28-
29-
backgroundColor: siteVariables.gray09,
33+
borderColor: siteVariables.gray08,
34+
borderRadius: pxToRem(3),
35+
backgroundColor: siteVariables.gray10,
3036
backgroundColorHover: siteVariables.gray08,
3137
textColor: siteVariables.colors.grey[900],
38+
textColorHover: siteVariables.colors.grey[900],
39+
boxShadow: siteVariables.shadowLevel1,
3240

3341
progressColor: siteVariables.naturalColors.lightGreen[900],
3442
progressHeight: 4,
3543

3644
headerFontSize: siteVariables.fontSizes.medium,
3745
headerFontWeight: siteVariables.fontWeightSemibold,
38-
headerLineHeight: siteVariables.lineHeightSmall,
46+
headerLineHeight: siteVariables.lineHeightMedium,
3947

4048
descriptionFontSize: siteVariables.fontSizes.small,
4149
descriptionFontWeight: siteVariables.fontWeightRegular,
4250
descriptionLineHeight: siteVariables.lineHeightSmall,
4351

44-
focusOutlineColor: siteVariables.colors.primary[500],
52+
focusInnerBorderColor: siteVariables.colors.white,
53+
focusOuterBorderColor: siteVariables.colors.black,
4554
})

0 commit comments

Comments
 (0)