rough-native
Version:
Create graphics using HTML Canvas or SVG with a hand-drawn, sketchy, appearance. Features comprehensive React hooks, memory management, and React 18 concurrent rendering support.
29 lines (28 loc) • 596 B
JavaScript
class WebPlatform {
isReactNative() {
return false;
}
isWeb() {
return true;
}
createSVGElement(tagName) {
return document.createElementNS('http://www.w3.org/2000/svg', tagName);
}
getDocument() {
return document;
}
}
class ReactNativePlatform {
isReactNative() {
return true;
}
isWeb() {
return false;
}
}
export const Platform = (() => {
if (typeof document !== 'undefined' && typeof window !== 'undefined') {
return new WebPlatform();
}
return new ReactNativePlatform();
})();