Skip to content

Commit

Permalink
Merge branch 'main' into tooltip-spec
Browse files Browse the repository at this point in the history
  • Loading branch information
aidendk authored Jun 14, 2022
2 parents 15075a5 + 34452e5 commit cf73edd
Show file tree
Hide file tree
Showing 12 changed files with 217 additions and 123 deletions.
15 changes: 15 additions & 0 deletions angular-workspace/projects/ni/nimble-angular/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
{
"name": "@ni/nimble-angular",
"entries": [
{
"date": "Mon, 13 Jun 2022 22:34:57 GMT",
"tag": "@ni/nimble-angular_v7.0.2",
"version": "7.0.2",
"comments": {
"patch": [
{
"author": "beachball",
"package": "@ni/nimble-angular",
"comment": "Bump @ni/nimble-components to v11.0.2",
"commit": "c930471568477d0b665ce9039cd13a73511b5c8e"
}
]
}
},
{
"date": "Tue, 07 Jun 2022 15:43:41 GMT",
"tag": "@ni/nimble-angular_v7.0.1",
Expand Down
10 changes: 9 additions & 1 deletion angular-workspace/projects/ni/nimble-angular/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
# Change Log - @ni/nimble-angular

This log was last generated on Tue, 07 Jun 2022 15:43:41 GMT and should not be manually modified.
This log was last generated on Mon, 13 Jun 2022 22:34:57 GMT and should not be manually modified.

<!-- Start content -->

## 7.0.2

Mon, 13 Jun 2022 22:34:57 GMT

### Patches

- Bump @ni/nimble-components to v11.0.2

## 7.0.1

Tue, 07 Jun 2022 15:43:41 GMT
Expand Down
4 changes: 2 additions & 2 deletions angular-workspace/projects/ni/nimble-angular/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ni/nimble-angular",
"version": "7.0.1",
"version": "7.0.2",
"description": "Angular components for the NI Nimble Design System",
"scripts": {
"invoke-publish": "cd ../../../ && npm run build:library && cd dist/ni/nimble-angular && npm publish"
Expand All @@ -22,7 +22,7 @@
"@angular/core": "^12.1.0",
"@angular/forms": "^12.1.0",
"@angular/router": "^12.1.0",
"@ni/nimble-components": "^11.0.1"
"@ni/nimble-components": "^11.0.2"
},
"dependencies": {
"tslib": "^2.2.0"
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/nimble-blazor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ni/nimble-blazor",
"version": "5.0.1",
"version": "5.0.2",
"description": "Blazor components for the NI Nimble Design System",
"scripts": {
"build": "npm run generate-icons && npm run build:release && npm run build:client",
Expand Down
30 changes: 30 additions & 0 deletions packages/nimble-components/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
{
"name": "@ni/nimble-components",
"entries": [
{
"date": "Mon, 13 Jun 2022 22:34:57 GMT",
"tag": "@ni/nimble-components_v11.0.2",
"version": "11.0.2",
"comments": {
"patch": [
{
"author": "[email protected]",
"package": "@ni/nimble-components",
"commit": "c930471568477d0b665ce9039cd13a73511b5c8e",
"comment": "Text/Number fields hover indicator grows from middle"
}
]
}
},
{
"date": "Wed, 08 Jun 2022 18:11:53 GMT",
"tag": "@ni/nimble-components_v11.0.1",
"version": "11.0.1",
"comments": {
"none": [
{
"author": "[email protected]",
"package": "@ni/nimble-components",
"commit": "d928589a70a2c14d2845ac81863c6f6f56eade1c",
"comment": "Change test to use IntersectionObserver"
}
]
}
},
{
"date": "Tue, 07 Jun 2022 15:43:41 GMT",
"tag": "@ni/nimble-components_v11.0.1",
Expand Down
10 changes: 9 additions & 1 deletion packages/nimble-components/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
# Change Log - @ni/nimble-components

This log was last generated on Tue, 07 Jun 2022 15:43:41 GMT and should not be manually modified.
This log was last generated on Mon, 13 Jun 2022 22:34:57 GMT and should not be manually modified.

<!-- Start content -->

## 11.0.2

Mon, 13 Jun 2022 22:34:57 GMT

### Patches

- Text/Number fields hover indicator grows from middle ([ni/nimble@c930471](https://github.com/ni/nimble/commit/c930471568477d0b665ce9039cd13a73511b5c8e))

## 11.0.1

Tue, 07 Jun 2022 15:43:41 GMT
Expand Down
2 changes: 1 addition & 1 deletion packages/nimble-components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ni/nimble-components",
"version": "11.0.1",
"version": "11.0.2",
"description": "Styled web components for the NI Nimble Design System",
"scripts": {
"build": "npm run generate-icons && npm run build-components && npm run bundle-components && npm run generate-scss && npm run build-storybook",
Expand Down
75 changes: 55 additions & 20 deletions packages/nimble-components/src/number-field/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import {
controlLabelFontColor,
labelHeight,
smallDelay,
bodyFont
bodyFont,
failColor,
standardPadding
} from '../theme-provider/design-tokens';

export const styles = css`
Expand All @@ -26,51 +28,90 @@ export const styles = css`
user-select: none;
color: ${bodyFontColor};
height: calc(${labelHeight} + ${controlHeight});
--ni-private-hover-indicator-width: calc(${borderWidth} + 1px);
}
:host([disabled]) {
color: ${bodyDisabledFontColor};
cursor: default;
}
.label {
display: flex;
color: ${controlLabelFontColor};
font: ${controlLabelFont};
}
.root {
box-sizing: border-box;
position: relative;
display: flex;
flex-direction: row;
justify-content: center;
border-radius: 0px;
border-bottom: ${borderWidth} solid rgba(${borderRgbPartialColor}, 0.3);
padding-bottom: 1px;
transition: border-bottom ${smallDelay}, padding-bottom ${smallDelay};
gap: calc(${standardPadding} / 2);
}
.root:focus-within {
border-bottom-color: ${borderHoverColor};
}
:host([disabled]) .root,
:host([disabled]) .root:hover {
border-bottom: ${borderWidth} solid ${bodyDisabledFontColor};
}
.root::before {
${/* Empty string causes alignment issue */ ''}
content: ' ';
color: transparent;
width: 0px;
user-select: none;
}
.root::after {
content: '';
position: absolute;
bottom: calc(-1 * ${borderWidth});
width: 0px;
height: 0px;
border-bottom: ${borderHoverColor}
var(--ni-private-hover-indicator-width) solid;
transition: width ${smallDelay} ease-in;
}
@media (prefers-reduced-motion) {
.root {
.root::after {
transition-duration: 0s;
}
}
.root:hover {
border-bottom: 2px solid ${borderHoverColor};
padding-bottom: 0px;
:host(.invalid) .root::after {
border-bottom-color: ${failColor};
}
:host([disabled]) .root,
:host([disabled]) .root:hover {
border-bottom: ${borderWidth} solid ${bodyDisabledFontColor};
padding-bottom: 1px;
:host(:hover) .root::after {
width: 100%;
}
:host([disabled]:hover) .root::after {
width: 0px;
}
[part='start'] {
display: contents;
}
.control {
-webkit-appearance: none;
font: inherit;
background: transparent;
color: inherit;
height: 28px;
height: calc(${controlHeight} - ${borderWidth});
width: 100%;
margin-top: auto;
margin-bottom: auto;
border: none;
padding: 0px;
}
.control:hover,
Expand All @@ -97,12 +138,6 @@ export const styles = css`
color: ${bodyDisabledFontColor};
}
.label {
display: flex;
color: ${controlLabelFontColor};
font: ${controlLabelFont};
}
.controls {
display: flex;
flex-direction: column;
Expand Down
55 changes: 37 additions & 18 deletions packages/nimble-components/src/select/tests/select.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,33 @@ async function setup(
return fixture<Select>(viewTemplate);
}

async function clickAndWaitForOpen(select: Select): Promise<void> {
select.click();
// Takes two updates for listbox to be rendered
await DOM.nextUpdate();
await DOM.nextUpdate();
}

async function checkFullyInViewport(element: HTMLElement): Promise<boolean> {
return new Promise((resolve, _reject) => {
const intersectionObserver = new IntersectionObserver(
entries => {
intersectionObserver.disconnect();
if (
entries[0]?.isIntersecting
&& entries[0].intersectionRatio === 1.0
) {
resolve(true);
} else {
resolve(false);
}
},
{ threshold: 1.0 }
);
intersectionObserver.observe(element);
});
}

describe('Select', () => {
it('should respect value set before connect is completed', async () => {
const { element, connect, disconnect } = await setup();
Expand Down Expand Up @@ -86,26 +113,18 @@ describe('Select', () => {
const { element, connect, disconnect } = await setup500Options();
await connect();
const listbox: HTMLElement = element.shadowRoot!.querySelector('.listbox')!;

element.click();
await DOM.nextUpdate();
await clickAndWaitForOpen(element);
// The test is run in an iframe, and the containing window has a Karma header.
// It seems the window is sized without accounting for the header, so a header-height's
// worth of content is scrolled out of view. The approach we take with the
// IntersectionObserver only works if the full iframe is visible, so we scroll the
// containing window to the bottom (i.e. scrolling the Karma header out of view and
// the bottom of the iframe into view).
window.parent.scrollTo(0, window.parent.document.body.scrollHeight);
const fullyVisible = await checkFullyInViewport(listbox);

expect(listbox.scrollHeight).toBeGreaterThan(window.innerHeight);

// listbox will pop up either above or below the element, depending on which has
// more space (the element is placed at a random vertical position within the window)
const listboxPadding = 4;
const controlPlusGapHeight = element.offsetHeight + listboxPadding;
const totalEmptyVerticalSpace = window.innerHeight - controlPlusGapHeight;
const largestEmptyVerticalSpan = element.offsetTop < totalEmptyVerticalSpace / 2
? window.innerHeight
- element.offsetTop
- controlPlusGapHeight
: element.offsetTop - listboxPadding;

expect(listbox.offsetHeight).toBeLessThanOrEqual(
largestEmptyVerticalSpan
);
expect(fullyVisible).toBe(true);

await disconnect();
});
Expand Down
Loading

0 comments on commit cf73edd

Please sign in to comment.