MCPcopy Create free account
hub / github.com/DavidHDev/react-bits / buildStudioUrl

Function buildStudioUrl

src/components/common/Preview/OpenInStudioButton.jsx:6–24  ·  view source on GitHub ↗
(backgroundId, currentProps = {}, defaultProps = {})

Source from the content-addressed store, hash-verified

4import { colors } from '../../../constants/colors';
5
6export function buildStudioUrl(backgroundId, currentProps = {}, defaultProps = {}) {
7 const params = new URLSearchParams();
8 params.set('bg', backgroundId);
9
10 Object.keys(currentProps).forEach(key => {
11 if (JSON.stringify(currentProps[key]) !== JSON.stringify(defaultProps[key])) {
12 const value = currentProps[key];
13 if (Array.isArray(value)) {
14 params.set(key, value.map(v => (typeof v === 'string' ? v.replace(/^#/, '') : v)).join(','));
15 } else if (typeof value === 'string' && value.startsWith('#')) {
16 params.set(key, value.replace(/^#/, ''));
17 } else {
18 params.set(key, String(value));
19 }
20 }
21 });
22
23 return `/tools/background-studio?${params.toString()}`;
24}
25
26const OpenInStudioButton = ({ backgroundId, currentProps = {}, defaultProps = {} }) => {
27 const navigate = useNavigate();

Callers 2

TabsLayoutFunction · 0.90
handleClickFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected