-
-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca9b164
commit 4568481
Showing
27 changed files
with
90 additions
and
70 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
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
6 changes: 4 additions & 2 deletions
6
packages/embla-carousel-docs/src/components/CodeSandbox/React/createSandboxReactFooter.ts
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
3 changes: 1 addition & 2 deletions
3
packages/embla-carousel-docs/src/components/CodeSandbox/React/createSandboxReactHeader.ts
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
6 changes: 4 additions & 2 deletions
6
packages/embla-carousel-docs/src/components/CodeSandbox/React/createSandboxReactImagePath.ts
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,5 +1,7 @@ | ||
import { renameImportPath } from '../sandboxUtils' | ||
const IMAGE_BY_INDEX_IMPORT_REGEX = /import(.*)from\s'..\/imageByIndex/ | ||
|
||
export const createSandboxReactImagePath = (carouselScript: string): string => { | ||
return renameImportPath(carouselScript, '../imageByIndex', './imageByIndex') | ||
return carouselScript.replace(IMAGE_BY_INDEX_IMPORT_REGEX, (match) => | ||
match.replace('../', './'), | ||
) | ||
} |
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
2 changes: 1 addition & 1 deletion
2
packages/embla-carousel-docs/src/components/CodeSandbox/React/createSandboxReactIndexHtml.ts
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
11 changes: 6 additions & 5 deletions
11
.../embla-carousel-docs/src/components/CodeSandbox/Vanilla/createSandboxVanillaImagePaths.ts
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,12 +1,13 @@ | ||
import { SANDBOX_VANILLA_FOLDERS } from './sandboxVanillaFolders' | ||
|
||
const REMOVE_IMAGE_HASH_REGEX = /(?<=slide-\d)(.*?)(?=.jpg)/g | ||
const REWRITE_IMAGE_PATH_REGEX = /\/static\//g | ||
const IMG_SRC_WITH_HASH_REGEX = /\/static\/slide-\d{1,}-.+?\./g | ||
const IMG_SLIDE_WITH_NUMBER_REGEX = /slide-\d{1,}/ | ||
|
||
export const createSandboxVanillaImagePaths = ( | ||
carouselHtml: string, | ||
): string => { | ||
return carouselHtml | ||
.replace(REMOVE_IMAGE_HASH_REGEX, '') | ||
.replace(REWRITE_IMAGE_PATH_REGEX, `${SANDBOX_VANILLA_FOLDERS.IMAGES}/`) | ||
return carouselHtml.replace(IMG_SRC_WITH_HASH_REGEX, (match) => { | ||
const slideWithNumber = match.match(IMG_SLIDE_WITH_NUMBER_REGEX) || [] | ||
return `${SANDBOX_VANILLA_FOLDERS.IMAGES}/${slideWithNumber}.` | ||
}) | ||
} |
10 changes: 6 additions & 4 deletions
10
...ges/embla-carousel-docs/src/components/CodeSandbox/Vanilla/createSandboxVanillaOptions.ts
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,15 +1,17 @@ | ||
import { EmblaOptionsType } from 'embla-carousel-react' | ||
import { | ||
injectSandboxIosPickerLoop, | ||
injectSandboxOptions, | ||
SANDBOX_REGEX_IOS_PICKER_LOOP, | ||
SANDBOX_REGEX_OPTIONS, | ||
} from '../sandboxRegex' | ||
} from '../sandboxUtils' | ||
|
||
export const createSandboxVanillaOptions = ( | ||
carouselScript: string, | ||
options: EmblaOptionsType, | ||
): string => { | ||
const iosPickerLoop = options?.loop || false | ||
const loop = options?.loop | ||
return carouselScript | ||
.replace(SANDBOX_REGEX_OPTIONS, JSON.stringify(options)) | ||
.replace(SANDBOX_REGEX_IOS_PICKER_LOOP, iosPickerLoop.toString()) | ||
.replace(SANDBOX_REGEX_OPTIONS, injectSandboxOptions(options)) | ||
.replace(SANDBOX_REGEX_IOS_PICKER_LOOP, injectSandboxIosPickerLoop(loop)) | ||
} |
17 changes: 0 additions & 17 deletions
17
packages/embla-carousel-docs/src/components/CodeSandbox/sandboxRegex.ts
This file was deleted.
Oops, something went wrong.
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
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
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
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
Oops, something went wrong.