-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Custom Border Radius Generator (#215)
* feat: Custom Border Radius Generator * changes done Co-authored-by: Dunsin <78784850+Dun-sin@users.noreply.github.com>
- Loading branch information
1 parent
0b3e8ff
commit 46f8925
Showing
5 changed files
with
254 additions
and
3 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
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,58 @@ | ||
import * as utils from '../lib/general'; | ||
|
||
type Values = { | ||
BorderTop: string; | ||
borderLeft: string; | ||
borderRight: string; | ||
borderBottom: string; | ||
}; | ||
|
||
export function borderRadiusGenerator(): void { | ||
const attribute = 'border-radius'; | ||
const getOutputElement = utils.getOutput(attribute); | ||
const resultPage = utils.getResultPage(); | ||
|
||
resultPage.style.display = 'flex'; | ||
if (getOutputElement === null) return; | ||
getOutputElement.style.display = 'grid'; | ||
getOutputElement.style.placeItems = 'center'; | ||
|
||
const borderTop = utils.getBorderTop(attribute); | ||
const borderRight = utils.getBorderRight(attribute); | ||
const borderLeft = utils.getBorderLeft(attribute); | ||
const borderBottom = utils.getBorderBottom(attribute); | ||
|
||
const values = { | ||
BorderTop: borderTop.value, | ||
borderLeft: borderLeft.value, | ||
borderRight: borderRight.value, | ||
borderBottom: borderBottom.value, | ||
}; | ||
|
||
getBorderRadiusResult(attribute, values, getOutputElement); | ||
} | ||
|
||
function getBorderRadiusResult( | ||
attribute: string, | ||
values: Values, | ||
outputElement: HTMLElement | ||
): void { | ||
outputElement.style.width = '250px'; | ||
outputElement.style.height = '250px'; | ||
outputElement.style.borderRadius = `${values.BorderTop}% ${ | ||
100 - Number(values.BorderTop) | ||
}% | ||
${values.borderBottom}% ${100 - Number(values.borderBottom)}% / | ||
${values.borderLeft}% ${values.borderRight}% | ||
${100 - Number(values.borderRight)}% ${100 - Number(values.borderLeft)}%`; | ||
|
||
const getCodeButtonElement = utils.getCopyCodeButton(attribute); | ||
getCodeButtonElement.addEventListener('click', () => { | ||
utils.copyCodeToClipboard(attribute, outputElement); | ||
utils.showPopup( | ||
'Code Copied', | ||
'Code has been successfully copied to clipboard', | ||
'success' | ||
); | ||
}); | ||
} |
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
46f8925
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.
Successfully deployed to the following URLs:
code-magic – ./
trick-generator.vercel.app
code-magic-dun-sin.vercel.app
code-magic.vercel.app
code-magic-git-main-dun-sin.vercel.app