Skip to content

Commit 77a2a54

Browse files
authored
feat: Tile manager component
Closes #1379
1 parent af19fb6 commit 77a2a54

File tree

76 files changed

+8787
-32
lines changed

Some content is hidden

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

76 files changed

+8787
-32
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
66

77
## [Unreleased]
88
### Added
9+
- Tile manager component [#1402](https://github.com/IgniteUI/igniteui-webcomponents/pull/1402)
910
- #### List
1011
- The `igc-list-item` component exposes a new `selected` property. When set on a list item, the item will become visually highlighted.
1112

package-lock.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"globby": "^14.1.0",
8080
"husky": "^9.1.7",
8181
"ig-typedoc-theme": "^6.0.0",
82-
"igniteui-theming": "^16.0.0",
82+
"igniteui-theming": "^16.1.0",
8383
"keep-a-changelog": "^2.6.1",
8484
"lint-staged": "^15.4.3",
8585
"lit-analyzer": "^2.0.3",

src/animations/player.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,19 @@ export function addAnimationController(
8585
) {
8686
return new AnimationController(host, target);
8787
}
88+
89+
type ViewTransitionResult = {
90+
transition?: ViewTransition;
91+
};
92+
93+
export function startViewTransition(
94+
callback?: ViewTransitionUpdateCallback
95+
): ViewTransitionResult {
96+
/* c8 ignore next 4 */
97+
if (getPrefersReducedMotion() || !document.startViewTransition) {
98+
callback?.();
99+
return {};
100+
}
101+
102+
return { transition: document.startViewTransition(callback) };
103+
}

src/components/carousel/carousel-indicator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { consume } from '@lit/context';
22
import { LitElement, html } from 'lit';
33
import { property } from 'lit/decorators.js';
44
import { styleMap } from 'lit/directives/style-map.js';
5+
import { carouselContext } from '../common/context.js';
56
import { registerComponent } from '../common/definitions/register.js';
67
import { formatString } from '../common/util.js';
78
import type IgcCarouselComponent from './carousel.js';
8-
import { carouselContext } from './context.js';
99
import { styles } from './themes/carousel-indicator.base.css.js';
1010

1111
/**

src/components/carousel/carousel-slide.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import { property } from 'lit/decorators.js';
44

55
import { EaseInOut } from '../../animations/easings.js';
66
import { addAnimationController } from '../../animations/player.js';
7+
import { carouselContext } from '../common/context.js';
78
import { registerComponent } from '../common/definitions/register.js';
89
import { createCounter, formatString } from '../common/util.js';
910
import { animations } from './animations.js';
1011
import type IgcCarouselComponent from './carousel.js';
11-
import { carouselContext } from './context.js';
1212
import { styles } from './themes/carousel-slide.base.css.js';
1313

1414
/**

src/components/carousel/carousel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { type Ref, createRef, ref } from 'lit/directives/ref.js';
1111
import { styleMap } from 'lit/directives/style-map.js';
1212
import { themes } from '../../theming/theming-decorator.js';
1313
import IgcButtonComponent from '../button/button.js';
14+
import { carouselContext } from '../common/context.js';
1415
import { addKeyboardFocusRing } from '../common/controllers/focus-ring.js';
1516
import {
1617
type SwipeEvent,
@@ -46,7 +47,6 @@ import IgcIconComponent from '../icon/icon.js';
4647
import IgcCarouselIndicatorContainerComponent from './carousel-indicator-container.js';
4748
import IgcCarouselIndicatorComponent from './carousel-indicator.js';
4849
import IgcCarouselSlideComponent from './carousel-slide.js';
49-
import { carouselContext } from './context.js';
5050
import { styles } from './themes/carousel.base.css.js';
5151
import { all } from './themes/container.js';
5252
import { styles as shared } from './themes/shared/carousel.common.css.js';

src/components/carousel/context.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/components/common/context.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { createContext } from '@lit/context';
2+
import type { Ref } from 'lit/directives/ref.js';
3+
import type IgcCarouselComponent from '../carousel/carousel.js';
4+
import type IgcTileManagerComponent from '../tile-manager/tile-manager.js';
5+
6+
export type TileManagerContext = {
7+
/** The igc-tile-manager instance. */
8+
instance: IgcTileManagerComponent;
9+
/** The internal CSS grid container of the igc-tile-manager. */
10+
grid: Ref<HTMLElement>;
11+
};
12+
13+
const carouselContext = createContext<IgcCarouselComponent>(
14+
Symbol('carousel-context')
15+
);
16+
17+
const tileManagerContext = createContext<TileManagerContext>(
18+
Symbol('tile-manager-context')
19+
);
20+
21+
export { carouselContext, tileManagerContext };
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { type Context, ContextConsumer, type ContextType } from '@lit/context';
2+
import type {
3+
LitElement,
4+
ReactiveController,
5+
ReactiveControllerHost,
6+
} from 'lit';
7+
8+
type AsyncContextOptions<T extends Context<unknown, unknown>> = {
9+
context: T;
10+
callback?: (value: ContextType<T>, dispose?: () => void) => void;
11+
subscribe?: boolean;
12+
};
13+
14+
/* blazorSuppress */
15+
export class AsyncContextConsumer<
16+
T extends Context<unknown, unknown>,
17+
Host extends ReactiveControllerHost & HTMLElement,
18+
> implements ReactiveController
19+
{
20+
protected _host: Host;
21+
protected _options: AsyncContextOptions<T>;
22+
protected _consumer?: ContextConsumer<T, Host>;
23+
24+
constructor(host: Host, options: AsyncContextOptions<T>) {
25+
this._host = host;
26+
this._options = options;
27+
28+
this._host.addController(this);
29+
}
30+
31+
public get value(): ContextType<T> | undefined {
32+
return this._consumer?.value;
33+
}
34+
35+
public async hostConnected(): Promise<void> {
36+
await this._host.updateComplete;
37+
38+
// If there is already an instance of a consumer (because of an attach/detach cycle),
39+
// skip creating a new instance for this host.
40+
if (!this._consumer) {
41+
this._consumer = new ContextConsumer(this._host, {
42+
context: this._options.context,
43+
callback: this._options.callback,
44+
subscribe: this._options.subscribe,
45+
});
46+
}
47+
}
48+
}
49+
50+
export function createAsyncContext<
51+
T extends Context<unknown, unknown>,
52+
Host extends ReactiveControllerHost & LitElement,
53+
>(
54+
host: Host,
55+
context: T,
56+
callback?: (value: ContextType<T>, dispose?: () => void) => void
57+
): AsyncContextConsumer<T, Host> {
58+
return new AsyncContextConsumer(host, {
59+
context,
60+
callback,
61+
subscribe: true,
62+
}) as AsyncContextConsumer<T, Host>;
63+
}

0 commit comments

Comments
 (0)