-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] bugs of Observed Attribute , Async Cell & Read Me
- Loading branch information
Showing
11 changed files
with
201 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { observable } from 'mobx'; | ||
import { importCSS } from 'web-utility'; | ||
|
||
import { WebCellProps } from '../Async'; | ||
import { animated } from '../MobX'; | ||
import { WebCell, component } from '../WebCell'; | ||
import { FC, attribute, observer, reaction } from '../decorator'; | ||
import { AnimationType } from './type'; | ||
|
||
export * from './type'; | ||
|
||
export interface AnimateCSS extends WebCell {} | ||
|
||
export interface AnimateCSSProps { | ||
type: AnimationType; | ||
component: FC<WebCellProps>; | ||
} | ||
|
||
@component({ tagName: 'animation-css' }) | ||
@observer | ||
export class AnimateCSS extends HTMLElement implements WebCell { | ||
declare props: AnimateCSSProps; | ||
|
||
@attribute | ||
@observable | ||
accessor type: AnimationType; | ||
|
||
@attribute | ||
@observable | ||
accessor playing = false; | ||
|
||
component: FC<WebCellProps>; | ||
|
||
async connectedCallback() { | ||
await importCSS('https://unpkg.com/animate.css@4/animate.min.css'); | ||
|
||
this.typeChanged(); | ||
} | ||
|
||
@reaction(({ type }) => type) | ||
async typeChanged() { | ||
this.playing = true; | ||
|
||
await animated(this, '.animate__animated'); | ||
|
||
this.playing = false; | ||
} | ||
|
||
render() { | ||
const { type, playing, component: Tag } = this; | ||
|
||
return playing ? ( | ||
<Tag className={`animate__animated animate__${type}`} /> | ||
) : type.includes('Out') ? ( | ||
<></> | ||
) : ( | ||
<Tag /> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
export type PositionY = 'Top' | 'Bottom'; | ||
export type DirectionX = 'Left' | 'Right'; | ||
export type DirectionY = 'Up' | 'Down'; | ||
export type Direction = DirectionX | DirectionY; | ||
export type AnimationMode = 'In' | 'Out'; | ||
|
||
export type AttentionSeekers = | ||
| 'bounce' | ||
| 'flash' | ||
| 'pulse' | ||
| 'rubberBand' | ||
| `shake${'X' | 'Y'}` | ||
| 'headShake' | ||
| 'swing' | ||
| 'tada' | ||
| 'wobble' | ||
| 'jello' | ||
| 'heartBeat'; | ||
export type BackEntrances = `backIn${Direction}`; | ||
export type BackExits = `backOut${Direction}`; | ||
export type BouncingEntrances = `bounceIn${'' | Direction}`; | ||
export type BouncingExits = `bounceOut${'' | Direction}`; | ||
export type FadingEntrances = | ||
| `fadeIn${'' | `${Direction}${'' | 'Big'}`}` | ||
| `fadeIn${PositionY}${DirectionX}`; | ||
export type FadingExits = `fadeOut${ | ||
| '' | ||
| `${Direction}${'' | 'Big'}` | ||
| `${PositionY}${DirectionX}`}`; | ||
export type Flippers = `flip${'' | `${AnimationMode}${'X' | 'Y'}`}`; | ||
export type Lightspeed = `lightSpeed${AnimationMode}${DirectionX}`; | ||
export type RotatingEntrances = `rotateIn${'' | `${DirectionY}${DirectionX}`}`; | ||
export type RotatingExits = `rotateOut${'' | `${DirectionY}${DirectionX}`}`; | ||
export type Specials = 'hinge' | 'jackInTheBox' | `roll${'In' | 'Out'}`; | ||
export type ZoomingEntrances = `zoomIn${'' | Direction}`; | ||
export type ZoomingExits = `zoomOut${'' | Direction}`; | ||
export type SlidingEntrances = `slideIn${Direction}`; | ||
export type SlidingExits = `slideOut${Direction}`; | ||
|
||
export type AnimationType = | ||
| AttentionSeekers | ||
| BackEntrances | ||
| BackExits | ||
| BouncingEntrances | ||
| BouncingExits | ||
| FadingEntrances | ||
| FadingExits | ||
| Flippers | ||
| Lightspeed | ||
| RotatingEntrances | ||
| RotatingExits | ||
| Specials | ||
| ZoomingEntrances | ||
| ZoomingExits | ||
| SlidingEntrances | ||
| SlidingExits; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
cb1a16c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for web-cell ready!
✅ Preview
https://web-cell-4r2kv2d4i-techquery.vercel.app
Built with commit cb1a16c.
This pull request is being automatically deployed with vercel-action