-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement custom entry #325
Open
mrm007
wants to merge
11
commits into
seek-oss:master
Choose a base branch
from
mrm007:entry
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3aa9edd
implement single entry
mrm007 9cfc647
add integration tests for single entry
mrm007 c443e0d
use mjs
mrm007 4eea27b
use live module bindings
mrm007 d32d505
add changeset
mrm007 e2b5918
simplify custom entry
mrm007 504da1a
add the possibility to define multiple entries
mrm007 4e3c670
add tests for multiple entries
mrm007 92a3fce
Merge remote-tracking branch 'origin/master' into entry
mrm007 a6ce975
update tests after merge
mrm007 a3ca889
a bit of gold plating
mrm007 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
'playroom': minor | ||
--- | ||
|
||
Add custom entry file support | ||
|
||
You can provide a custom entry file via the `entry` option, which is a path to a file that runs some code before everything else. For example, if you wanted to apply a CSS reset or other global styles, polyfills etc.: | ||
|
||
```js | ||
import '../path/to/your/theming-system/reset'; | ||
import '../path/to/your/theming-system/global-styles.css'; | ||
``` | ||
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 | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -62,6 +62,7 @@ module.exports = { | |||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
// Optional: | ||||||||||||||||||||||||||||||
title: 'My Awesome Library', | ||||||||||||||||||||||||||||||
entry: './src/entry', | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||
themes: './src/themes', | ||||||||||||||||||||||||||||||
snippets: './playroom/snippets.js', | ||||||||||||||||||||||||||||||
frameComponent: './playroom/FrameComponent.js', | ||||||||||||||||||||||||||||||
|
@@ -158,6 +159,15 @@ export default function useScope() { | |||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
## Custom Entry | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
You can provide a custom entry file via the `entry` option, which is a path to a file that runs some code before everything else. For example, if you wanted to apply a CSS reset or other global styles, polyfills etc.: | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
```js | ||||||||||||||||||||||||||||||
import '../path/to/your/theming-system/reset'; | ||||||||||||||||||||||||||||||
import '../path/to/your/theming-system/global-styles.css'; | ||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||
Comment on lines
+166
to
+169
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
## Theme Support | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
If your component library has multiple themes, you can customise Playroom to render every theme simultaneously via the `themes` configuration option. | ||||||||||||||||||||||||||||||
|
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { assertPreviewContains, typeCode, visit } from '../support/utils'; | ||
|
||
describe('entry', () => { | ||
const assertGlobalCounter = () => | ||
cy.window().its('counter').should('equal', 1); | ||
|
||
describe('loads the entry only once', () => { | ||
it('for main app', () => { | ||
cy.visit('http://localhost:9002'); | ||
// introduce some delay to make sure everything loads | ||
typeCode('-'); | ||
|
||
assertGlobalCounter(); | ||
}); | ||
|
||
it('for frames', () => { | ||
visit('http://localhost:9002'); | ||
// introduce some delay to make sure everything loads | ||
typeCode('-'); | ||
|
||
assertGlobalCounter(); | ||
}); | ||
|
||
it('for preview', () => { | ||
cy.visit( | ||
'http://localhost:9002/preview#code=N4Igxg9gJgpiBcIC0IC%2BQ' | ||
).then(() => { | ||
cy.get('[data-testid="splashscreen"]').should('not.be.visible'); | ||
}); | ||
// wait for rendering to finish to make sure everything loads | ||
assertPreviewContains('-'); | ||
|
||
assertGlobalCounter(); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { counter, increment } from './state.mjs'; | ||
|
||
export default counter; | ||
|
||
increment(); |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* eslint-disable no-console */ | ||
|
||
export let counter = 0; | ||
|
||
export function increment() { | ||
window.counter = ++counter; | ||
|
||
console.log('incremented', window.counter); | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
// this doesn't do anything by default |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.