Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Users/jes/expand collapse hover state #16375

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
8912d32
Merge pull request #1 from microsoft/master
eljefe223 Sep 17, 2020
7f2afc9
Merge branch 'master' of https://github.com/microsoft/fluentui
eljefe223 Sep 18, 2020
b97a477
Merge branch 'master' of https://github.com/microsoft/fluentui
eljefe223 Sep 23, 2020
1d450b7
Merge branch 'master' of https://github.com/microsoft/fluentui
eljefe223 Sep 23, 2020
abc1aac
Merge branch 'master' of https://github.com/microsoft/fluentui
eljefe223 Sep 23, 2020
f40c04e
Merge branch 'master' of https://github.com/microsoft/fluentui
eljefe223 Nov 9, 2020
57d97a5
Merge branch 'master' of https://github.com/microsoft/fluentui
eljefe223 Nov 16, 2020
82b70f4
Merge branch 'master' of https://github.com/microsoft/fluentui
eljefe223 Nov 16, 2020
c67924a
Merge branch 'master' of https://github.com/microsoft/fluentui
eljefe223 Nov 17, 2020
937ab9e
Merge branch 'master' of https://github.com/microsoft/fluentui
eljefe223 Nov 20, 2020
204c744
Merge branch 'master' of https://github.com/microsoft/fluentui
eljefe223 Nov 20, 2020
cfdf698
Merge branch 'master' of https://github.com/microsoft/fluentui
eljefe223 Nov 24, 2020
4d62088
Merge branch 'master' of https://github.com/microsoft/fluentui
eljefe223 Dec 1, 2020
ac92354
Merge branch 'master' of https://github.com/microsoft/fluentui
eljefe223 Dec 16, 2020
8b1e138
Merge branch 'master' of https://github.com/microsoft/fluentui
eljefe223 Dec 17, 2020
1cd5f4c
Merge branch 'master' of https://github.com/microsoft/fluentui
eljefe223 Dec 17, 2020
600c579
Merge branch 'master' of https://github.com/microsoft/fluentui
eljefe223 Jan 5, 2021
1909d3e
fix: add hover state for expand collapse button in tree-item
eljefe223 Jan 5, 2021
2c5aa58
Change files
eljefe223 Jan 5, 2021
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "patch",
"comment": "fix: add hover state for expand collapse button in tree-item",
"packageName": "@fluentui/web-components",
"email": "jes@microsoft.com",
"dependentChangeType": "patch",
"date": "2021-01-05T20:23:56.895Z"
}
72 changes: 57 additions & 15 deletions packages/web-components/src/tree-item/tree-item.styles.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { css } from '@microsoft/fast-element';
import {
cssCustomPropertyBehaviorFactory,
DirectionalStyleSheetBehavior,
disabledCursor,
display,
focusVisible,
forcedColorsStylesheetBehavior,
} from '@microsoft/fast-foundation';
import { SystemColors } from '@microsoft/fast-web-utilities';
import { neutralFillStealthHover, neutralFillStealthSelected } from '@microsoft/fast-components-styles-msft';
import {
accentForegroundRestBehavior,
heightNumber,
Expand All @@ -20,6 +22,8 @@ import {
neutralForegroundRestBehavior,
} from '../styles/index';

import { FluentDesignSystemProvider } from '../design-system-provider/index';

const ltr = css`
.expand-collapse-glyph {
transform: rotate(-45deg);
Expand Down Expand Up @@ -50,6 +54,21 @@ const rtl = css`
}
`;

export const expandCollapseButtonSize =
'((var(--base-height-multiplier) / 2) * var(--design-unit)) + ((var(--design-unit) * var(--density)) / 2)';

const expandCollapseHoverBehavior = cssCustomPropertyBehaviorFactory(
'neutral-stealth-hover-over-hover',
x => neutralFillStealthHover(neutralFillStealthHover)(x),
FluentDesignSystemProvider.findProvider,
);

const selectedExpandCollapseHoverBehavior = cssCustomPropertyBehaviorFactory(
'neutral-stealth-hover-over-selected',
x => neutralFillStealthHover(neutralFillStealthSelected)(x),
FluentDesignSystemProvider.findProvider,
);

export const TreeItemStyles = css`
${display('block')} :host {
contain: content;
Expand Down Expand Up @@ -82,7 +101,7 @@ export const TreeItemStyles = css`
position: relative;
box-sizing: border-box;
border: transparent calc(var(--outline-width) * 1px) solid;
height: calc(${heightNumber} * 1px);
height: calc((${heightNumber} + 1) * 1px);
}

.positioning-region::before {
Expand All @@ -101,12 +120,12 @@ export const TreeItemStyles = css`
}

.content-region {
display: flex;
display: inline-flex;
align-items: center;
white-space: nowrap;
width: 100%;
height: calc(${heightNumber} * 1px);
margin-inline-start: calc(var(--design-unit) * 2px + 2px);
margin-inline-start: calc(var(--design-unit) * 2px + 8px);
font-size: var(--type-ramp-base-font-size);
line-height: var(--type-ramp-base-line-height);
font-weight: 400;
Expand All @@ -127,13 +146,14 @@ export const TreeItemStyles = css`
${
/* Width and Height should be based off calc(glyph-size-number + (design-unit * 4) * 1px) -
update when density story is figured out */ ''
} width: var(--expand-collapse-button-size);
height: var(--expand-collapse-button-size);
} width: calc((${expandCollapseButtonSize} + (var(--design-unit) * 2)) * 1px);
height: calc((${expandCollapseButtonSize} + (var(--design-unit) * 2)) * 1px);
padding: 0;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
margin: 0 6px;
}

.expand-collapse-glyph {
Expand Down Expand Up @@ -182,10 +202,27 @@ export const TreeItemStyles = css`
cursor: ${disabledCursor};
}

:host(.nested) .content-region {
position: relative;
margin-inline-start: var(--expand-collapse-button-size);
}

:host(.nested) .expand-collapse-button {
position: absolute;
}

:host(.nested) .expand-collapse-button:hover {
background: ${expandCollapseHoverBehavior.var};
}

:host([selected]) .positioning-region {
background: ${neutralFillStealthSelectedBehavior.var};
}

:host([selected]) .expand-collapse-button:hover {
background: ${selectedExpandCollapseHoverBehavior.var};
}

:host([selected])::after {
content: "";
display: block;
Expand All @@ -200,22 +237,13 @@ export const TreeItemStyles = css`
border-radius: calc(var(--corner-radius) * 1px);
}

:host(.nested) .content-region {
position: relative;
margin-inline-start: var(--expand-collapse-button-size);
}

:host(.nested) .expand-collapse-button {
position: absolute;
left: var(--expand-collapse-button-nested-width, calc(${heightNumber} * -1px));
}

::slotted(fluent-tree-item) {
--tree-item-nested-width: 1em;
--expand-collapse-button-nested-width: calc(${heightNumber} * -1px);
}
`.withBehaviors(
accentForegroundRestBehavior,
expandCollapseHoverBehavior,
neutralFillStealthSelectedBehavior,
neutralFillStealthActiveBehavior,
neutralFillStealthHoverBehavior,
Expand All @@ -224,13 +252,15 @@ export const TreeItemStyles = css`
neutralFocusInnerAccentBehavior,
neutralForegroundActiveBehavior,
neutralForegroundRestBehavior,
selectedExpandCollapseHoverBehavior,
new DirectionalStyleSheetBehavior(ltr, rtl),
forcedColorsStylesheetBehavior(
css`
:host {
forced-color-adjust: none;
border-color: transparent;
background: ${SystemColors.Field};
color: ${SystemColors.FieldText};
}
:host .content-region {
color: ${SystemColors.FieldText};
Expand Down Expand Up @@ -262,6 +292,7 @@ export const TreeItemStyles = css`
:host(:${focusVisible}) .positioning-region {
border-color: ${SystemColors.FieldText};
box-shadow: 0 0 0 2px inset ${SystemColors.Field};
color: ${SystemColors.FieldText};
}
:host([disabled]) .content-region,
:host([disabled]) .positioning-region:hover .content-region {
Expand All @@ -279,6 +310,17 @@ export const TreeItemStyles = css`
:host([disabled]) .positioning-region:hover {
background: ${SystemColors.Field};
}
.expand-collapse-glyph,
.start,
.end {
fill: ${SystemColors.FieldText};
}
:host(.nested) .expand-collapse-button:hover {
background: ${SystemColors.Field};
}
:host(.nested) .expand-collapse-button:hover .expand-collapse-glyph {
fill: ${SystemColors.FieldText};
}
`,
),
);