Skip to content

Commit

Permalink
Merge pull request #68 from borulday/master
Browse files Browse the repository at this point in the history
Fix typo on "getRelativePosition" method
  • Loading branch information
Andreslav committed Aug 14, 2020
2 parents 23100ee + 5ba9e2e commit 7c8df7f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { set } from 'lodash'
import { createFigma } from 'figma-api-stub'
import { getRealtivePosition } from '../src'
import { getRelativePosition } from '../src'

const GAP = 50
const X = 'absoluteTransform[0][2]'
Expand All @@ -20,7 +20,7 @@ frameNode2.appendChild(frameNode3)
frameNode1.appendChild(frameNode2)
pageNode.appendChild(frameNode1)

describe('getRealtivePosition', () => {
describe('getRelativePosition', () => {
beforeEach(() => {
set(frameNode1, X, 0)
set(frameNode1, Y, 0)
Expand All @@ -39,7 +39,7 @@ describe('getRealtivePosition', () => {
})

test('calculations for zero values', () => {
expect(getRealtivePosition(textNode)).toEqual({ x: 0, y: 0 })
expect(getRelativePosition(textNode)).toEqual({ x: 0, y: 0 })
})
test('ignore positions of nodes between targets', () => {
set(frameNode2, X, GAP * 100)
Expand All @@ -50,14 +50,14 @@ describe('getRealtivePosition', () => {
set(frameNode3, Y, GAP * 50)
set(frameNode4, Y, GAP * 25)
set(textNode, Y, GAP * 2)
expect(getRealtivePosition(textNode)).toEqual({ x: GAP, y: GAP * 2 })
expect(getRelativePosition(textNode)).toEqual({ x: GAP, y: GAP * 2 })
})
test('calculations should ignore top level node position', () => {
set(frameNode1, X, GAP)
set(textNode, X, GAP * 3)
set(frameNode1, Y, GAP)
set(textNode, Y, GAP * 6)
expect(getRealtivePosition(textNode)).toEqual({ x: GAP * 3 - GAP, y: GAP * 6 - GAP })
expect(getRelativePosition(textNode)).toEqual({ x: GAP * 3 - GAP, y: GAP * 6 - GAP })
})
test('calculations with provided parent', () => {
set(frameNode2, X, GAP * 100)
Expand All @@ -68,7 +68,7 @@ describe('getRealtivePosition', () => {
set(frameNode3, Y, GAP * 50)
set(frameNode4, Y, GAP * 25)
set(textNode, Y, GAP * 2)
expect(getRealtivePosition(textNode, frameNode3)).toEqual({
expect(getRelativePosition(textNode, frameNode3)).toEqual({
x: GAP * 50 - GAP,
y: GAP * 50 - GAP * 2
})
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@figma-plugin/helpers",
"version": "0.14.1",
"version": "0.14.2",
"description": "A collection of helper functions useful when creating Figma plugins",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ export const getTopLevelParent = (node: BaseNode): BaseNode => {
* // for structure below
* // Page / Frame / Group1 / Group2 / Text
*
* getRealtivePosition(Text, Group1) // will calculate { x, y } based on Group1
* getRelativePosition(Text, Group1) // will calculate { x, y } based on Group1
*
* getRealtivePosition(Text) // will calculate { x, y } based on Frame
* getRelativePosition(Text) // will calculate { x, y } based on Frame
* ```
**/
export const getRealtivePosition = (
export const getRelativePosition = (
node: BaseNode & LayoutMixin,
relativeNode?: BaseNode & LayoutMixin
) => {
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { nodeToObject } from './helpers/nodeToObject'
import topLevelFrames from './helpers/topLevelFrames'
import { getTextNodeCSS } from './helpers/getCSSStyles'
import { findAll } from './helpers/findMethods'
import { getRealtivePosition, getTopLevelParent } from './helpers/getRealtivePosition'
import { getRelativePosition, getTopLevelParent } from './helpers/getRelativePosition'
import {
figmaRGBToWebRGB,
webRGBToFigmaRGB,
Expand Down Expand Up @@ -69,7 +69,7 @@ export {
webRGBToFigmaRGB,
figmaRGBToHex,
hexToFigmaRGB,
getRealtivePosition,
getRelativePosition,
getTopLevelParent,
hasChildren,
findAll,
Expand Down

0 comments on commit 7c8df7f

Please sign in to comment.