@@ -13,6 +13,10 @@ import {
1313 getDegreeSpanElement ,
1414 getGradientPreview ,
1515 getTailwindButton ,
16+ getCssOrTailwindButton ,
17+ getCssOrTailwindDropdown ,
18+ getPngOrSvgButton ,
19+ getPngOrSvgDropdown ,
1620} from '../lib/getElements' ;
1721import {
1822 copyCSSCodeToClipboard ,
@@ -27,6 +31,7 @@ import {
2731 createGradientPreview ,
2832 getColorsValue ,
2933 copyTailwindCodeToClipboard ,
34+ closeDropdown ,
3035} from '../lib/packages' ;
3136
3237type Values = {
@@ -42,6 +47,10 @@ const getRemoveColorButtonElement = getRemoveNewColorButton(attribute);
4247
4348const getDegreeElement = getRange ( attribute ) ;
4449const resetButton = getResetButton ( attribute ) ;
50+ const getCssOrTailwindDropdownElement = getCssOrTailwindDropdown ( attribute ) ;
51+ const getPngOrSvgDropdownElement = getPngOrSvgDropdown ( attribute ) ;
52+ const showCopyClass = 'show-css-tailwind' ;
53+ const showPngOrSvgClass = 'show-png-svg' ;
4554
4655function copyHandler ( ) {
4756 const outputElement = getOutput ( attribute ) ;
@@ -53,6 +62,22 @@ function copyHandler() {
5362 ) ;
5463}
5564
65+ function getCssOrTailwind ( e ?: MouseEvent ) : void {
66+ e ?. stopPropagation ( ) ;
67+ getCssOrTailwindDropdownElement . classList . toggle ( showCopyClass ) ;
68+ }
69+
70+ function getPngOrSvg ( e ?: MouseEvent ) {
71+ e ?. stopPropagation ( ) ;
72+ getPngOrSvgDropdownElement . classList . toggle ( showPngOrSvgClass ) ;
73+ }
74+
75+ // closes css and tailwind dropdown on outside click
76+ closeDropdown ( getCssOrTailwind , getCssOrTailwindDropdownElement , showCopyClass ) ;
77+
78+ // closes png and css dropdown outside click
79+ closeDropdown ( getPngOrSvg , getPngOrSvgDropdownElement , showPngOrSvgClass ) ;
80+
5681function pngDownloadHandler ( ) {
5782 const outputElement = getOutput ( attribute ) ;
5883 downloadPNG ( attribute , outputElement ) ;
@@ -127,6 +152,8 @@ function getGradientTextResult(
127152 const getPNGButtonElement = getPNGButton ( attribute ) ;
128153 const getSVGButtonElement = getSVGButton ( attribute ) ;
129154 const getTailwindCodeButtonElement = getTailwindButton ( attribute ) ;
155+ const getCssOrTailwindButtonElement = getCssOrTailwindButton ( attribute ) ;
156+ const getPngOrSvgButtonElement = getPngOrSvgButton ( attribute ) ;
130157
131158 if ( outputElement . childElementCount >= 1 ) {
132159 outputElement . innerHTML = '' ;
@@ -142,6 +169,10 @@ function getGradientTextResult(
142169 getCodeButtonElement . addEventListener ( 'click' , copyHandler ) ;
143170
144171 getTailwindCodeButtonElement . addEventListener ( 'click' , tailwindHandler ) ;
172+
173+ getCssOrTailwindButtonElement . addEventListener ( 'click' , getCssOrTailwind ) ;
174+
175+ getPngOrSvgButtonElement . addEventListener ( 'click' , getPngOrSvg ) ;
145176}
146177
147178export function addGradientTextListener ( ) {
0 commit comments