MCPcopy Create free account
hub / github.com/callstack/react-native-paper / CodePreview

Function CodePreview

docs/src/components/DynamicColorTheme.tsx:143–182  ·  view source on GitHub ↗
({
  theme,
  children,
}: {
  theme: Record<string, any>;
  children: ReactNode | undefined;
})

Source from the content-addressed store, hash-verified

141};
142
143const CodePreview = ({
144 theme,
145 children,
146}: {
147 theme: Record<string, any>;
148 children: ReactNode | undefined;
149}) => {
150 const [copied, setCopied] = useState(false);
151
152 const getColorScheme = () => {
153 return JSON.stringify(
154 {
155 colors: theme,
156 },
157 null,
158 2
159 );
160 };
161
162 const onCopy = () => {
163 navigator.clipboard.writeText(getColorScheme());
164 setCopied(true);
165
166 setTimeout(() => setCopied(false), 1000);
167 };
168
169 return (
170 <div>
171 <div className="color-picker-schema-copy-header">
172 <h4>{children}</h4>
173 <button onClick={onCopy} className="color-picker-action-button">
174 {copied ? 'copied' : 'copy'}
175 </button>
176 </div>
177 <pre>
178 <code className="language-json">{getColorScheme()}</code>
179 </pre>
180 </div>
181 );
182};
183
184let uniqColorKey = 0;
185

Callers

nothing calls this directly

Calls 1

getColorSchemeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…