From ec8c4823e86121fa5581ab3938e99809d8133d8b Mon Sep 17 00:00:00 2001 From: mhmo91 Date: Sat, 18 Jan 2025 08:34:33 +0100 Subject: [PATCH] . --- demo/src/features/typewriter.ts | 27 +++++----- package.json | 2 +- src/divider/divider.ts | 92 +++++++++++++++++++++++++++++---- 3 files changed, 99 insertions(+), 22 deletions(-) diff --git a/demo/src/features/typewriter.ts b/demo/src/features/typewriter.ts index 0197c76..75203f0 100644 --- a/demo/src/features/typewriter.ts +++ b/demo/src/features/typewriter.ts @@ -6,18 +6,21 @@ import { customElement } from 'lit/decorators.js' export class SchmancyTypewriterDemo extends $LitElement() { render() { return html` - - Hello, world! - - Welcome to Schmancy. - - Lit Components! - - - We empower organizations to operate -

Efficiently, Seamlessly, and Affordably

-

Through digital transformation.

-
+ + + Hello, world! + + Welcome to Schmancy. + + Lit Components! + + + + We empower organizations to operate +

Efficiently, Seamlessly, and Affordably

+

Through digital transformation.

+
+
` } } diff --git a/package.json b/package.json index ba68f0a..37380fa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mhmo91/schmancy", - "version": "0.0.290", + "version": "0.0.291", "description": "UI library build with web components", "main": "./dist/index.js", "repository": { diff --git a/src/divider/divider.ts b/src/divider/divider.ts index 87cf554..cda30f6 100644 --- a/src/divider/divider.ts +++ b/src/divider/divider.ts @@ -2,31 +2,105 @@ import { $LitElement } from '@mixins/index' import { css, html } from 'lit' import { customElement, property } from 'lit/decorators.js' +import { classMap } from 'lit/directives/class-map.js' @customElement('schmancy-divider') export default class SchmancyDivider extends $LitElement(css` :host { display: block; + overflow: hidden; /* Ensure the animation is clipped */ } - :host([orientation='horizontal']) { + .divider { + /* Maintain existing border-based color logic */ + border-color: var(--divider-color, currentColor); + } + /* Horizontal Divider */ + .horizontal { width: 100%; height: 1px; + border-top: 1px solid; + transform: scaleX(0); + transform-origin: var(--transform-origin, left); + animation: drawHorizontal var(--animation-duration, 1s) forwards; } - :host([orientation='vertical']) { - height: 100%; + /* Vertical Divider */ + .vertical { width: 1px; + height: 100%; + border-left: 1px solid; + transform: scaleY(0); + transform-origin: var(--transform-origin, top); + animation: drawVertical var(--animation-duration, 1s) forwards; + } + /* Outline Variants */ + .border-outlineVariant { + /* Utilize existing outline variant styles */ + border-color: var(--outline-variant-color, #555); + } + .border-outline { + /* Utilize existing default outline styles */ + border-color: var(--outline-color, #000); + } + /* RTL Support for Horizontal Dividers */ + :host([dir='rtl']) .horizontal.grow-start { + --transform-origin: right; + } + :host([dir='rtl']) .horizontal.grow-end { + --transform-origin: left; + } + /* Center Growth for Horizontal and Vertical Dividers */ + .horizontal.grow-both { + --transform-origin: center; + } + .vertical.grow-both { + --transform-origin: center; + } + /* Define Keyframes */ + @keyframes drawHorizontal { + to { + transform: scaleX(1); + } + } + @keyframes drawVertical { + to { + transform: scaleY(1); + } + } + /* Assign Animations Based on Grow Direction */ + .horizontal.grow-start { + animation: drawHorizontal var(--animation-duration, 1s) forwards; + } + .horizontal.grow-end { + animation: drawHorizontal var(--animation-duration, 1s) forwards; + } + .horizontal.grow-both { + animation: drawHorizontal var(--animation-duration, 1s) forwards; + } + + .vertical.grow-start { + animation: drawVertical var(--animation-duration, 1s) forwards; + } + .vertical.grow-end { + animation: drawVertical var(--animation-duration, 1s) forwards; + } + .vertical.grow-both { + animation: drawVertical var(--animation-duration, 1s) forwards; } `) { - @property() outline: 'default' | 'variant' = 'variant' - @property({ reflect: true }) orientation: 'horizontal' | 'vertical' = 'horizontal' - protected render(): unknown { + @property({ type: String }) outline: 'default' | 'variant' = 'variant' + @property({ reflect: true, type: String }) orientation: 'horizontal' | 'vertical' = 'horizontal' + @property({ type: String }) grow: 'start' | 'end' | 'both' = 'start' + + protected render() { const classes = { - 'border-t': this.orientation === 'horizontal', - 'border-l h-full': this.orientation === 'vertical', + divider: true, + horizontal: this.orientation === 'horizontal', + vertical: this.orientation === 'vertical', 'border-outlineVariant': this.outline === 'variant', 'border-outline': this.outline === 'default', + [`grow-${this.grow}`]: true, // e.g., grow-start, grow-end, grow-both } - return html`
` + return html`
` } }