(backgroundId, currentProps = {}, defaultProps = {})
| 4 | import { colors } from '../../../constants/colors'; |
| 5 | |
| 6 | export 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 | |
| 26 | const OpenInStudioButton = ({ backgroundId, currentProps = {}, defaultProps = {} }) => { |
| 27 | const navigate = useNavigate(); |
no outgoing calls
no test coverage detected