@@ -3,21 +3,22 @@ import {html, LitElement, PropertyValues} from "lit";
33import tailwindCss from '../styles/tailwind.min.css?raw' ;
44import TailwindElement from "../app/TailwindElement" ;
55
6+ import './LucideIcon' ;
7+
68export interface BlnButtonProps {
7- variant ?: 'primary ' | 'link' ;
9+ variant ?: 'solid ' | 'outline' | 'ghost' | 'soft' | ' link' | 'arrow' | 'arrow-red ';
810 withArrow : boolean ,
911 withStripes : boolean ,
1012 size ?: 'small' | 'medium' | 'large' ;
1113 label : string ;
1214 onClick ?: ( ) => void ;
1315 disabled ?: boolean ;
1416 class ?: string ;
17+ retroDesign : boolean ;
1518}
1619
1720@customElement ( 'bln-button' )
1821export class BlnButton extends TailwindElement {
19- // Cache für geladene Tailwind-CSS (einmal pro Seite)
20-
2122 /**
2223 * Represents an HTML button element type.
2324 *
@@ -43,17 +44,14 @@ export class BlnButton extends TailwindElement {
4344 *
4445 * Possible value: "primary"
4546 */
46- @property ( { type : String } ) variant = "primary " ;
47+ @property ( { type : String } ) variant = "solid " ;
4748
4849
4950 /**
50- * Represents the size of an object or entity.
51- *
52- * This variable is typically used to define or adjust configurations,
53- * properties, or appearances where size is a consideration.
54- *
55- * Possible values may include descriptive size terms such as
56- * "small", "medium", "large", or custom definitions based on context.
51+ * Represents the size of an item or element.
52+ * This variable holds a string value indicating the size classification.
53+ * Commonly used to define or adjust dimensions, layouts, or options.
54+ * Possible values might include "small", "medium", "large", etc.
5755 */
5856 @property ( { type : String } ) size = "medium" ;
5957
@@ -74,13 +72,10 @@ export class BlnButton extends TailwindElement {
7472 */
7573 @property ( { type : Boolean , reflect : true } ) disabled = false ;
7674
77-
7875 /**
7976 * This variable indicates whether a striped effect is applied or not.
8077 * It is a boolean value that defaults to false, implying that the striped effect
8178 * is disabled unless explicitly set to true.
82- *
83- * @type {boolean }
8479 */
8580 @property ( { type : Boolean , attribute : "with-stripes" } ) withStripes = false ;
8681
@@ -100,71 +95,80 @@ export class BlnButton extends TailwindElement {
10095 */
10196 @property ( { attribute : false } ) onClick ?: ( e : MouseEvent ) => void ;
10297
103- protected firstUpdated ( _changedProperties : PropertyValues ) {
104- super . firstUpdated ( _changedProperties ) ;
105-
106- }
107-
108-
109-
110-
11198 /**
11299 * Renders a button with customizable styles and behaviors based on properties such as size, variant, arrow inclusion, and disabled state.
113100 * The method dynamically constructs the button's classes, applies relevant styles, and optionally renders a right arrow icon based on button configuration.
114101 */
115102 renderButton ( ) {
116- // Button types
117- const isLink = this . variant === 'link' ;
118-
119- // Classes
120- const base = isLink
121- ? "border-2 border-[#e40422] bg-white font-bold"
122- : "border-2 border-black bg-white" ;
123- const size = this . size === 'small' ? 'text-sm' : this . size === 'large' ? 'text-lg' : '' ;
124- const padding = isLink
125- ? this . size === 'small'
126- ? 'py-2 px-3'
127- : 'py-3 px-4'
128- : this . withArrow
129- ? ''
130- : this . size === 'small'
131- ? 'py-1 px-3'
132- : 'py-2 px-5' ;
133- const hover = ! this . disabled && ! isLink ? 'hover:bg-gray-200' : isLink ? 'hover:underline' : '' ;
134- const disabled = this . disabled ? 'opacity-50 cursor-not-allowed' : '' ;
135- const spanClasses = this . withArrow
136- ? this . size === 'small'
137- ? 'py-1 px-3 border-r-2 border-black'
138- : 'py-2 px-5 border-r-2 border-black'
139- : '' ;
140- const buttonClasses = [
141- 'transition duration-700 flex items-stretch' ,
142- base ,
143- disabled ,
144- size ,
145- padding ,
146- hover ,
147- this . class , // zusätzliche Host-übergebene Klassen
148- ] . filter ( Boolean ) . join ( ' ' ) ;
149-
150- const arrayBGColor = this . variant === 'secondary' ? "black" : "#e40422" ;
151-
152- // Render
153103 return html `
154- <!-- Tailwind aus Storybook Static Dir -->
155- <!-- <link rel="stylesheet" href="/tailwind.css"/>-->
156-
157- < button class ="${ buttonClasses } "
104+ < button class ="${ this . cn (
105+ 'transition duration-700 disabled:pointer-events-none' ,
106+ [
107+ this . retroDesign
108+ ? 'inline-flex border-2 font-semibold border-black bg-white hover:bg-gray-200'
109+ : 'inline-flex items-center gap-x-2 text-sm font-medium rounded border focus:outline-hidden' ,
110+ this . disabled
111+ ? 'disabled:cursor-not-allowed disabled:opacity-50'
112+ : '' ,
113+ ( this . variant === 'solid' || this . variant === null ) && ! this . retroDesign
114+ ? 'bg-blue-500 text-white hover:bg-blue-600 focus:bg-blue-600 border-transparent'
115+ : '' ,
116+ this . variant === 'outline' && ! this . retroDesign
117+ ? 'border-gray-200 text-gray-500 hover:border-blue-600 hover:text-blue-600 focus:border-blue-600 focus:text-blue-600'
118+ : '' ,
119+ this . variant === 'ghost' && ! this . retroDesign
120+ ? 'border-transparent text-blue-500 hover:bg-blue-100 hover:text-blue-800 focus:bg-blue-100 focus:text-blue-800'
121+ : '' ,
122+ this . variant === 'soft' && ! this . retroDesign
123+ ? 'border-transparent bg-blue-100 text-blue-800 hover:bg-blue-200 focus:bg-blue-200'
124+ : '' ,
125+ this . variant === 'link'
126+ ? this . retroDesign
127+ ? 'border-2 !border-[#e40422] bg-white font-bold hover:!bg-transparent hover:underline'
128+ : 'border-transparent text-blue-500 hover:text-blue-700 focus:text-blue-700'
129+ : '' ,
130+ ( this . variant === 'arrow' || this . variant === 'arrow-red' ) && ! this . retroDesign
131+ ? 'border-transparent hover:text-gray-400 transition duration-700'
132+ : ''
133+ ]
134+ ) } "
158135 ?disabled =${ this . disabled }
159136 @click =${ ( e : MouseEvent ) => this . onClick ?.( e ) } >
160- < span class ="${ spanClasses } "> < slot > </ slot > </ span >
161- ${ this . withArrow
137+ < span class ="${ this . cn ( [
138+ this . size === 'large'
139+ ? 'p-4 sm:p-5'
140+ : this . size === 'small'
141+ ? 'py-2 px-3'
142+ : 'py-3 px-4' ,
143+ this . variant === 'arrow' || this . variant === 'arrow-red'
144+ ? this . retroDesign
145+ ? 'border-r-2 border-black'
146+ : 'pr-1'
147+ : '' ,
148+ this . retroDesign
149+ ? ''
150+ : 'border-transparent' ,
151+ ] ) } "> < slot > </ slot > </ span >
152+ ${ this . variant === 'arrow' || this . variant === 'arrow-red'
162153 ? html `
163- < div class ="px-3 flex items-center " style ="background: ${ arrayBGColor } ; ">
164- < svg xmlns ="http://www.w3.org/2000/svg " viewBox ="0 0 448 512 " width ="15 " fill ="white ">
165- <!--! Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc. -->
166- < path d ="M438.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L338.8 224 32 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l306.7 0L233.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l160-160z "/>
167- </ svg >
154+ < div class ="${ this . cn ( [
155+ 'w-full flex items-center justify-center' ,
156+ this . variant === 'arrow'
157+ ? this . retroDesign
158+ ? 'bg-black px-3'
159+ : 'bg-gray-600 rounded-full p-2'
160+ : this . retroDesign
161+ ? 'bg-police-red px-3'
162+ : 'bg-police-red rounded-full p-2' ,
163+ ] ) } ">
164+ < lucide-icon name ="ArrowRight "
165+ cls ="${ this . cn ( [
166+ 'text-white' ,
167+ this . retroDesign
168+ ? 'w-6 h-6'
169+ : 'w-4 h-4' ,
170+ ] ) } ">
171+ </ lucide-icon >
168172 </ div > `
169173 : "" }
170174 </ button > ` ;
0 commit comments