generated from openedx/frontend-template-application
-
Notifications
You must be signed in to change notification settings - Fork 15
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
feat: A leaner example app that is built using Vite #54
Closed
Closed
Changes from all commits
Commits
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
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,18 @@ | ||
module.exports = { | ||
root: true, | ||
env: { browser: true, es2020: true }, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:react-hooks/recommended', | ||
], | ||
ignorePatterns: ['dist', '.eslintrc.cjs'], | ||
parser: '@typescript-eslint/parser', | ||
plugins: ['react-refresh'], | ||
rules: { | ||
'react-refresh/only-export-components': [ | ||
'warn', | ||
{ allowConstantExport: true }, | ||
], | ||
}, | ||
} |
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,24 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
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,156 @@ | ||
import { | ||
DIRECT_PLUGIN, | ||
IFRAME_PLUGIN, | ||
PLUGIN_OPERATIONS, | ||
} from '@openedx/frontend-plugin-framework'; | ||
// import DefaultDirectWidget from './src/components/DefaultDirectWidget'; | ||
import PluginDirect from './src/components/PluginDirect'; | ||
import ModularComponent from './src/components/ModularComponent'; | ||
|
||
const modifyWidget = (widget) => { | ||
const newContent = { | ||
title: 'Modified Modular Plugin', | ||
uniqueText: 'Note that the original text defined in the JS config is replaced by this modified one.', | ||
}; | ||
const modifiedWidget = widget; | ||
modifiedWidget.content = newContent; | ||
return modifiedWidget; | ||
}; | ||
|
||
const wrapWidget = ({ component, idx }) => ( | ||
<div className="bg-warning" data-testid={`wrapper${idx + 1}`} key={idx}> | ||
<p>This is a wrapper component that is placed around the default content.</p> | ||
{component} | ||
<p>With this wrapper, you can add anything before or after a component.</p> | ||
<p>Note in the JS config that an iFrame plugin was Inserted, but a Hide operation was also used to hide it!</p> | ||
</div> | ||
); | ||
|
||
// Note that in an actual application this file would be added to .gitignore. | ||
const config = { | ||
pluginSlots: { | ||
slot_with_insert_operation: { | ||
keepDefault: true, | ||
plugins: [ | ||
{ | ||
op: PLUGIN_OPERATIONS.Insert, | ||
widget: { | ||
id: 'inserted_direct_plugin', | ||
type: DIRECT_PLUGIN, | ||
priority: 10, | ||
RenderWidget: PluginDirect, | ||
}, | ||
}, | ||
{ | ||
op: PLUGIN_OPERATIONS.Insert, | ||
widget: { | ||
id: 'inserted_iframe_plugin', | ||
type: IFRAME_PLUGIN, | ||
priority: 30, | ||
url: 'http://localhost:8081/plugin_iframe', | ||
title: 'The iFrame plugin that is inserted in the slot', | ||
}, | ||
}, | ||
], | ||
}, | ||
slot_with_modify_wrap_hidden_operations: { | ||
keepDefault: true, | ||
plugins: [ | ||
{ | ||
op: PLUGIN_OPERATIONS.Insert, | ||
widget: { | ||
id: 'inserted_plugin', | ||
type: DIRECT_PLUGIN, | ||
priority: 10, | ||
RenderWidget: ModularComponent, | ||
content: { | ||
title: 'Modular Direct Plugin', | ||
uniqueText: 'This is some text that will be replaced by the Modify operation below.', | ||
}, | ||
}, | ||
}, | ||
{ | ||
op: PLUGIN_OPERATIONS.Insert, | ||
widget: { | ||
id: 'inserted_iframe_plugin', | ||
type: IFRAME_PLUGIN, | ||
priority: 30, | ||
url: 'http://localhost:8081/plugin_iframe', | ||
title: 'This iFrame plugin will be hidden due to the Hide operation in this config.', | ||
}, | ||
}, | ||
{ | ||
op: PLUGIN_OPERATIONS.Wrap, | ||
widgetId: 'default_contents', | ||
wrapper: wrapWidget, | ||
}, | ||
{ | ||
op: PLUGIN_OPERATIONS.Modify, | ||
widgetId: 'inserted_plugin', | ||
fn: modifyWidget, | ||
}, | ||
{ | ||
op: PLUGIN_OPERATIONS.Hide, | ||
widgetId: "inserted_iframe_plugin", | ||
}, | ||
], | ||
}, | ||
slot_with_modular_plugins: { | ||
keepDefault: true, | ||
plugins: [ | ||
{ | ||
op: PLUGIN_OPERATIONS.Insert, | ||
widget: { | ||
id: 'inserted_direct_plugin', | ||
type: DIRECT_PLUGIN, | ||
priority: 1, | ||
RenderWidget: ModularComponent, | ||
content: { | ||
title: 'Modular Direct Plugin', | ||
uniqueText: 'This is a direct plugin with priority of 1, which is why it appears first in this slot.', | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
slot_without_default: { | ||
keepDefault: false, | ||
plugins: [ | ||
{ | ||
op: PLUGIN_OPERATIONS.Insert, | ||
widget: { | ||
id: 'inserted_direct_plugin', | ||
type: DIRECT_PLUGIN, | ||
priority: 1, | ||
RenderWidget: ModularComponent, | ||
content: { | ||
title: 'Modular Direct Plugin With Content Defined in JS Config', | ||
uniqueText: 'This modular component receives some of its content from the JS config (such as this text).', | ||
}, | ||
}, | ||
}, | ||
{ | ||
op: PLUGIN_OPERATIONS.Insert, | ||
widget: { | ||
id: 'inserted_direct_plugin', | ||
type: DIRECT_PLUGIN, | ||
priority: 10, | ||
RenderWidget: PluginDirect, | ||
}, | ||
}, | ||
{ | ||
op: PLUGIN_OPERATIONS.Insert, | ||
widget: { | ||
id: 'inserted_iframe_plugin', | ||
type: IFRAME_PLUGIN, | ||
priority: 30, | ||
url: 'http://localhost:8081/plugin_iframe', | ||
title: 'The iFrame plugin that is inserted in the slot', | ||
}, | ||
}, | ||
], | ||
} | ||
}, | ||
}; | ||
|
||
export default config; |
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,13 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>frontend-plugin-framework demo</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.
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.
quick clarification on this: wouldn't changing the instruction here thus make the script
npm run start:example
irrelevant, and thus the Hostexample
app irrelevant? If there's a benefit to keeping both, then I think this instruction could flesh out the reasoning between using one over the other.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.
Yeah, if we decided we were OK with maintaining the Vite version (see also https://discuss.openedx.org/t/experiment-build-an-mfe-with-vite-instead-of-frontend-build-webpack/12702 ) then we could just straight-up replace the
example
app. I just thought some people might prefer to have one based onfrontend-build
for consistency.