Skip to content

Commit

Permalink
style: 💄 format
Browse files Browse the repository at this point in the history
  • Loading branch information
phun-ky committed Aug 23, 2024
1 parent fb5ec15 commit a4d440c
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 25 deletions.
20 changes: 10 additions & 10 deletions src/features/measure/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const element = async (targetElement: HTMLElement): Promise<void> => {

await waitForFrame();

const isSlim = _areas_string?.includes(MeasureAreaEnum.Slim);
const isSlim = _areas_string?.includes(MeasureAreaEnum.Slim);
const _target_rect = targetElement.getBoundingClientRect();
const widthModifier = !isSlim ? 48 : 0;
const heightModifier = !isSlim ? 96 : 0;
Expand All @@ -81,7 +81,7 @@ export const element = async (targetElement: HTMLElement): Promise<void> => {

const _positional_styles = await getRec(_measure_el, targetElement);

if(isSlim){
if (isSlim) {
const { left, top, width } = _positional_styles.fromBottom({
center: false
});
Expand All @@ -92,7 +92,7 @@ export const element = async (targetElement: HTMLElement): Promise<void> => {
width: `${width}px`
});
} else {
const { left, top, width,height } = _positional_styles.absolute({
const { left, top, width, height } = _positional_styles.absolute({
center: false
});

Expand All @@ -110,7 +110,7 @@ export const element = async (targetElement: HTMLElement): Promise<void> => {

const _positional_styles = await getRec(_measure_el, targetElement);

if(isSlim){
if (isSlim) {
const { left, top, width } = _positional_styles.fromTop({
center: false
});
Expand All @@ -120,14 +120,14 @@ export const element = async (targetElement: HTMLElement): Promise<void> => {
top: `${top}px`,
width: `${width}px`
});
} else{
} else {
const { left, top, width, height } = _positional_styles.absolute({
center: false
});

await addStyles(_measure_el, {
left: `${left}px`,
top: `${top -widthModifier}px`,
top: `${top - widthModifier}px`,
width: `${width}px`,
height: `${height + widthModifier}px`
});
Expand All @@ -141,8 +141,8 @@ export const element = async (targetElement: HTMLElement): Promise<void> => {

const _positional_styles = await getRec(_measure_el, targetElement);

if(isSlim){
const { left, top, height} = _positional_styles.fromRight({
if (isSlim) {
const { left, top, height } = _positional_styles.fromRight({
center: false
});

Expand All @@ -152,7 +152,7 @@ export const element = async (targetElement: HTMLElement): Promise<void> => {
height: `${height}px`
});
} else {
const { left, top, height, width} = _positional_styles.absolute({
const { left, top, height, width } = _positional_styles.absolute({
center: false
});

Expand All @@ -170,7 +170,7 @@ export const element = async (targetElement: HTMLElement): Promise<void> => {

const _positional_styles = await getRec(_measure_el, targetElement);

if(isSlim){
if (isSlim) {
const { left, top, height } = _positional_styles.fromLeft({
center: false
});
Expand Down
10 changes: 8 additions & 2 deletions src/features/pin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ export const pinElements = async (

if (!_els_to_be_pinned || _els_to_be_pinned.length === 0) return;

const _literals_to_use = sectionElement.getAttribute('data-speccer-literals') as string|null || window.SPECCER_LITERALS || SPECCER_LITERALS;
const _literals_to_use =
(sectionElement.getAttribute('data-speccer-literals') as string | null) ||
window.SPECCER_LITERALS ||
SPECCER_LITERALS;

[..._els_to_be_pinned]
.filter(
Expand All @@ -63,7 +66,10 @@ export const pinElements = async (
targetElement: HTMLElement,
targetIndex: number
): Promise<void> => {
const _character_to_use = getCharacterToUse(targetIndex,_literals_to_use);
const _character_to_use = getCharacterToUse(
targetIndex,
_literals_to_use
);

await pinElement(targetElement, _character_to_use, sectionElement);
}
Expand Down
5 changes: 4 additions & 1 deletion src/features/pin/utils/get-character-to-use.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ let _index_to_use = 0;
* const nextCharacter = getCharacterToUse(25); // Returns next character or a generated pair if index exceeds literals length
* ```
*/
export const getCharacterToUse = (targetIndex: number, literalsToUse: string|string[]): string => {
export const getCharacterToUse = (
targetIndex: number,
literalsToUse: string | string[]
): string => {
let _character_to_use = literalsToUse[targetIndex];

// Reset index to use when we start new elements
Expand Down
2 changes: 1 addition & 1 deletion src/features/spacing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const element = async (targetElement: HTMLElement): Promise<void> => {

if (!_target_pruned_spacing_styles.length) return;

_target_pruned_spacing_styles.forEach(async (property) =>{
_target_pruned_spacing_styles.forEach(async (property) => {
const _value = getNumberValue(_target_spacing_styles[property]);
const _speccer_el = create(_value);
const _class_name = getClassNameFromCSSProperty(property);
Expand Down
18 changes: 9 additions & 9 deletions src/features/spacing/utils/position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,29 @@ export const position = async (
addStyles(spacingElement, {
height: `${value}px`,
width: _target_rect.width + 96 + 'px',
left: _target_offset.left - 96+ 'px',
left: _target_offset.left - 96 + 'px',
top: _target_offset.top - value + 'px'
});

if (property === 'marginRight')
addStyles(spacingElement, {
height: _target_rect.height +48+ 'px',
height: _target_rect.height + 48 + 'px',
width: `${value}px`,
left: _target_offset.left + parseInt(_target_rect.width + '', 10) + 'px',
top: _target_offset.top+ 'px'
top: _target_offset.top + 'px'
});

if (property === 'marginBottom')
addStyles(spacingElement, {
height: `${value}px`,
width: _target_rect.width + 96 + 'px',
left: _target_offset.left - 96+ 'px',
left: _target_offset.left - 96 + 'px',
top: _target_offset.top + parseInt(_target_rect.height + '', 10) + 'px'
});

if (property === 'marginLeft')
addStyles(spacingElement, {
height: _target_rect.height +48+ 'px',
height: _target_rect.height + 48 + 'px',
width: `${value}px`,
left: _target_offset.left - value + 'px',
top: _target_offset.top + 'px'
Expand All @@ -65,15 +65,15 @@ export const position = async (
addStyles(spacingElement, {
height: `${value}px`,
width: _target_rect.width + 96 + 'px',
left: _target_offset.left - 96+ 'px',
left: _target_offset.left - 96 + 'px',
top: _target_offset.top + 'px'
});

if (property === 'paddingBottom')
addStyles(spacingElement, {
height: `${value}px`,
width: _target_rect.width + 96 + 'px',
left: _target_offset.left - 96+ 'px',
left: _target_offset.left - 96 + 'px',
top:
_target_offset.top +
(parseInt(_target_rect.height + '', 10) - value) +
Expand All @@ -82,7 +82,7 @@ export const position = async (

if (property === 'paddingRight')
addStyles(spacingElement, {
height: _target_rect.height +48 + 'px',
height: _target_rect.height + 48 + 'px',
width: `${value}px`,
left:
_target_offset.left +
Expand All @@ -96,6 +96,6 @@ export const position = async (
height: _target_rect.height + 48 + 'px',
width: `${value}px`,
left: _target_offset.left + 'px',
top: _target_offset.top +'px'
top: _target_offset.top + 'px'
});
};
10 changes: 9 additions & 1 deletion src/utils/bezier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,15 @@ export const getSVGPath = async (
pos2
);
const { firstPoint, firstControl, lastControl, lastPoint } =
createBezierCurveCoordinates({ x1, x2, y1: y1 +document.documentElement.scrollTop, y2: y2 + document.documentElement.scrollTop }, { direction: '' });
createBezierCurveCoordinates(
{
x1,
x2,
y1: y1 + document.documentElement.scrollTop,
y2: y2 + document.documentElement.scrollTop
},
{ direction: '' }
);

return (
`M ${firstPoint.x} ${firstPoint.y}` +
Expand Down
5 changes: 4 additions & 1 deletion src/utils/classes/DrawCircle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ export class DrawCircle {

this.circle.setAttribute('r', this.radius + ''); // SVG attributes
this.circle.setAttribute('cx', Math.round(x) + ''); // SVG attributes
this.circle.setAttribute('cy', Math.round(y + document.documentElement.scrollTop) + ''); // SVG attributes
this.circle.setAttribute(
'cy',
Math.round(y + document.documentElement.scrollTop) + ''
); // SVG attributes
this.circle.setAttribute('fill', 'currentColor'); // SVG attributes
}
}
Expand Down

0 comments on commit a4d440c

Please sign in to comment.