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

🚀 - New Skeleton API #6953

Closed
nsbarsukov opened this issue Mar 5, 2024 · 1 comment · Fixed by #6934
Closed

🚀 - New Skeleton API #6953

nsbarsukov opened this issue Mar 5, 2024 · 1 comment · Fixed by #6934
Assignees

Comments

@nsbarsukov
Copy link
Member

nsbarsukov commented Mar 5, 2024

Current implementation

It global class .tui-skeleton with modifiers.
skeleton-class

Learn more: https://taiga-ui.dev/skeleton

Problems:

  • Developer should duplicate enabling of the main class (and all other modifications) for EVERY element:
<div 
    [class.tui-skeleton_light]="lightMode"
    [class.tui-skeleton]="isSkeletonVisible"
></div>
  • No intermediate state (it is especially important for css animations – smooth appearing content after disabling of skeleton).

New proposed API

Introduce new TuiSkeletonDirective.
It uses tuiWithStyles inside to add :before/:after pseudo-elements.
It uses power of Dependency Injection.

Case 1. Configure all nested skeletons from the root element

<div [tuiSkeleton]="enabled">
  <img tuiSkeleton src="..." />

  <form>
    <tui-toggle tuiSkeleton></tui-toggle>

    <tui-input tuiSkeleton></tui-input>
  </form>

</div>

All TuiSkeletonDirective injects itself inside

@Optional()
@SkipSelf()
private readonly parentSkeleton: TuiSkeletonDirective,

And default value of its state (enabled/disabled) is equal to computed input-value of its nearest parent.
But develop can overwrite it and provide explicit input-prop to any nested skeleton.

Case 2. Replace legacy .tui-skeleton_light class with tuiMode-directive
Before:

<div 
    [class.tui-skeleton_light]="lightMode"
    [class.tui-skeleton]="enabled"
></div>

After:

<div 
    tuiMode="onLight"
    [tuiSkeleton]="enabled"
></div>

Case 3. Is .tui-skeleton_text actually required ?
Investigate should developer always mark all text-containers (a.k.a previous class .tui-skeleton_text).
Or we could do it automatically ?
For example, investigate if :after-element could always be non-breaking space

&_text:before {
content: '\a0';
}


New animation for switching between skeleton and animation

Cross-fade animation. Smoothly change of opacity on swithching.
Content dissappers / appears smoothly.
Skeleton appears/dissappers smoothly.

@nsbarsukov
Copy link
Member Author

nsbarsukov commented Mar 5, 2024

@waterplea also proposed solution with contrast(0).

Example with multi-line text:

background: red;
border-radius: 1rem;
box-decoration-break: clone;
filter: contrast(0) brightness(0);
opacity: 0.1;

TODO:
Investigate if we could use it.
How we can configure the background color of the skeleton ? 🤔

@nsbarsukov nsbarsukov linked a pull request Mar 5, 2024 that will close this issue
@nsbarsukov nsbarsukov assigned waterplea and unassigned nsbarsukov Mar 5, 2024
@github-project-automation github-project-automation bot moved this from 💡 Backlog to ✅ Done in Taiga-family Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants