forked from oyeolamilekan/appshots
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.ts
More file actions
60 lines (57 loc) · 1.68 KB
/
Copy pathutils.ts
File metadata and controls
60 lines (57 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* DeviceFrame Utility Functions
*
* Helper functions for computing styles and backgrounds
* for device frame elements.
*/
import type { DeviceColor } from "../../types";
/**
* Generates the background style for the device frame.
*
* @param color - The device color configuration
* @returns CSS background value (gradient or solid color)
*
* @example
* // With gradient colors
* getFrameBackground({ frameColors: ['#1a1a1a', '#2a2a2a', '#3a3a3a'], frame: '#000' })
* // Returns: "linear-gradient(135deg, #1a1a1a, #2a2a2a, #3a3a3a)"
*
* @example
* // With solid color
* getFrameBackground({ frame: '#000' })
* // Returns: "#000"
*/
export const getFrameBackground = (color: DeviceColor): string => {
if (color.frameColors) {
return `linear-gradient(135deg, ${color.frameColors.join(", ")})`;
}
return color.frame;
};
/**
* Generates the background style for device buttons.
* Creates a gradient that simulates 3D lighting based on button position.
*
* @param color - The device color configuration
* @param direction - Button position ('left' or 'right')
* @returns CSS background value for the button
*
* @example
* // Right-side button (light appears to come from left)
* getButtonBackground(color, 'right')
*
* @example
* // Left-side button (light appears to come from right)
* getButtonBackground(color, 'left')
*/
export const getButtonBackground = (
color: DeviceColor,
direction: "left" | "right",
): string => {
if (color.frameColors) {
const [first, , third] = color.frameColors;
return direction === "right"
? `linear-gradient(to right, ${third}, ${first})`
: `linear-gradient(to left, ${third}, ${first})`;
}
return color.frame;
};