Skip to content

Commit 19f5c50

Browse files
author
Maya Shavin
committed
feat: group x,y to position
1 parent 049f3f2 commit 19f5c50

2 files changed

Lines changed: 35 additions & 6 deletions

File tree

packages/url/lib/index.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { RESOURCE_TYPES, STORAGE_TYPES } from './constants'
1+
import { RESOURCE_TYPES, STORAGE_TYPES, ROTATION_MODES } from './constants'
22
import { CldOptions, CloudConfig } from './types/CldOptions'
33
import { url, extractPublicId } from './url'
44

5+
import { transform, toTransformationStr } from './transformers'
6+
57
let config = {}
68

79
export const getConfig = () => Object.freeze(config)
@@ -11,28 +13,43 @@ export const setConfig = (options:CloudConfig) => config = {
1113
...options
1214
}
1315

14-
export const buildUrl = (pubicId: string, { cloud = {}, transformations = {} }: CldOptions):string => {
16+
export const buildUrl = (publicId: string, { cloud = {}, transformations = {} }: CldOptions):string => {
1517
const cloudConfig = {
1618
...config,
1719
...cloud
1820
}
19-
return url(pubicId, cloudConfig, transformations)
21+
return url(publicId, cloudConfig, transformations)
2022
}
2123

22-
export const buildImageUrl = (pubicId: string, { cloud = {}, transformations = {} }: CldOptions):string => buildUrl(pubicId, {
24+
export const buildImageUrl = (publicId: string, { cloud = {}, transformations = {} }: CldOptions):string => buildUrl(publicId, {
2325
cloud: {
2426
...cloud,
2527
resourceType: RESOURCE_TYPES.IMAGE
2628
},
2729
transformations
2830
})
2931

30-
export const buildVideoUrl = (pubicId: string, { cloud = {}, transformations = {} }: CldOptions):string => buildUrl(pubicId, {
32+
export const buildVideoUrl = (publicId: string, { cloud = {}, transformations = {} }: CldOptions):string => buildUrl(publicId, {
3133
cloud: {
3234
...cloud,
3335
resourceType: RESOURCE_TYPES.VIDEO
3436
},
3537
transformations
3638
})
3739

38-
export { RESOURCE_TYPES, extractPublicId, STORAGE_TYPES }
40+
type TransformerType = { transform: typeof transform, toString: typeof toTransformationStr }
41+
42+
const Transformer:TransformerType = { transform, toString: toTransformationStr }
43+
44+
export { RESOURCE_TYPES, extractPublicId, STORAGE_TYPES, ROTATION_MODES, Transformer }
45+
46+
export type { CldOptions, TransformerOption, TransformerVideoOption, CloudConfig, Rotation } from './types/CldOptions'
47+
export type { ResourceType } from './types/ResourceType'
48+
export type { StorageType } from './types/StorageType'
49+
export type { ResizeType, Resize } from './transformers/resize'
50+
export type { Border } from './transformers/border'
51+
export type { CustomFunction } from './transformers/customFunc'
52+
export type { Position } from './transformers/position'
53+
export type { Effect } from './transformers/effect'
54+
55+
export default buildUrl
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
export interface Position{
3+
x?: number,
4+
y?: number
5+
}
6+
7+
export const position = ({ x, y }: Position) => {
8+
const xAxis = x ? `x_${x}` : ''
9+
const yAxis = y ? `y_${y}` : ''
10+
11+
return [xAxis, yAxis].filter(Boolean).join()
12+
}

0 commit comments

Comments
 (0)