-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from baurine/fix/navigator-not-defined
refactor(playground-nextjs): remove dynamic load
- Loading branch information
Showing
8 changed files
with
33 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,30 @@ | ||
function getOS() { | ||
let userAgent = navigator.userAgent | ||
if (/windows phone/i.test(userAgent)) { | ||
return 'Windows Phone' | ||
} else if (/android/i.test(userAgent)) { | ||
return 'Android' | ||
} else if (/iPad|iPhone|iPod/.test(userAgent)) { | ||
return 'iOS' | ||
} else if (/Macintosh|MacIntel|MacPPC|Mac68K/i.test(userAgent)) { | ||
return 'macOS' | ||
} else if (/Windows|Win16|Win32|WinCE|Win64/i.test(userAgent)) { | ||
return 'Windows' | ||
} else if (/Linux/i.test(userAgent)) { | ||
return 'Linux' | ||
} else { | ||
return 'Unknown OS' | ||
// ref: https://dev.to/vvo/how-to-solve-window-is-not-defined-errors-in-react-and-next-js-5f97 | ||
if (typeof window !== 'undefined') { | ||
let userAgent = navigator.userAgent | ||
if (/windows phone/i.test(userAgent)) { | ||
return 'Windows Phone' | ||
} else if (/android/i.test(userAgent)) { | ||
return 'Android' | ||
} else if (/iPad|iPhone|iPod/.test(userAgent)) { | ||
return 'iOS' | ||
} else if (/Macintosh|MacIntel|MacPPC|Mac68K/i.test(userAgent)) { | ||
return 'macOS' | ||
} else if (/Windows|Win16|Win32|WinCE|Win64/i.test(userAgent)) { | ||
return 'Windows' | ||
} else if (/Linux/i.test(userAgent)) { | ||
return 'Linux' | ||
} else { | ||
return 'Unknown OS' | ||
} | ||
} | ||
return 'Unknown OS' | ||
} | ||
|
||
export const os = getOS() | ||
export function os() { | ||
return getOS() | ||
} | ||
|
||
export const isAppleOs = ['macOS', 'iOS'].includes(os) | ||
export function isAppleOs() { | ||
return ['macOS', 'iOS'].includes(os()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 1 addition & 6 deletions
7
packages/playground-nextjs/app/playground/editor-panel/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
packages/playground-nextjs/components/biz/dynamic-editor-example.tsx
This file was deleted.
Oops, something went wrong.