Skip to content

Commit 4d63fe2

Browse files
aqsaaqeelAqsa Aqeel
andauthored
feat: tailwind border-radius code (#419)
* feat: tailwind border-radius code Added tailwind code generator for border radius property * fix: added custom value for radius * fix: build error fixed --------- Co-authored-by: Aqsa Aqeel <[email protected]>
1 parent eb705d0 commit 4d63fe2

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/lib/packages.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,12 @@ export function copyCSSCodeToClipboard(
7979
* @param attribute The attribute name of the generator element
8080
* @param outputElement output element to display result
8181
*/
82-
export function copyTailwindCodeToClipboard(attribute: string): void {
83-
actOnTailwindGenerator(attribute);
82+
export function copyTailwindCodeToClipboard(
83+
attribute: string,
84+
outputElement?: HTMLElement | null
85+
): void {
86+
if (outputElement) actOnTailwindGenerator(attribute, outputElement);
87+
else console.log("Can't generate tailwind code");
8488
}
8589

8690
export const addRule = (function (style) {
@@ -267,9 +271,12 @@ const actOnGenerator = (attribute: string, outputElement: HTMLElement) => {
267271
* @param attribute attribute of the clicked generator
268272
* @param outputElement output element to display result
269273
*/
270-
const actOnTailwindGenerator = (attribute: string) => {
274+
const actOnTailwindGenerator = (
275+
attribute: string,
276+
outputElement: HTMLElement
277+
) => {
278+
let element = outputElement.style;
271279
let codeToCopy = '';
272-
273280
switch (attribute) {
274281
case 'pic-text':
275282
codeToCopy = ``;
@@ -284,7 +291,7 @@ const actOnTailwindGenerator = (attribute: string) => {
284291
codeToCopy = ``;
285292
break;
286293
case 'border-radius':
287-
codeToCopy = ``;
294+
codeToCopy = `rounded-[${element.borderRadius.replace(/ /g, '_')}]`;
288295
break;
289296
case 'box-shadow':
290297
codeToCopy = ``;

src/pages/border-radius.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ getValues();
148148

149149
// Tailwind codecopy handler
150150
function tailwindHandler() {
151-
copyTailwindCodeToClipboard(attribute);
151+
const outputElement = getOutput(attribute);
152+
copyTailwindCodeToClipboard(attribute, outputElement);
152153
showPopup(
153154
'Tailwind Code Copied',
154155
'Code has been successfully copied to clipboard',

0 commit comments

Comments
 (0)