-
Notifications
You must be signed in to change notification settings - Fork 9
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
Sample extensions for different styling methods #7
Conversation
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
export default class ModulesStylingExtension extends LensRendererExtension { | ||
clusterPages = [ | ||
{ | ||
path: "/css-modules-styling-sample", |
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.
API is changed, now page-registration and page-menu-regisration are splitted.
Working example:
clusterPages = [
{
id: "example-page-id",
components: {
Page: () => <ExamplePage extension={this}/>,
}
}
]
clusterPageMenus = [
{
id: this.clusterPages[0].id, // must be the same as in page registration to be visible in sidebar
title: "Hello World",
components: {
Icon: ExampleIcon
}
}
]
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.
Starting the app with described changes and got
Uncaught TypeError: Expected "name" to match "[^\/#\?]+?", but got "@k8slens/styling-css-modules-sample"
at LensDev.js:402426
at n.getPageUrl (LensDev.js:521110)
at LensDev.js:523074
at Array.map (<anonymous>)
at PageMenuRegistry.getItems (LensDev.js:523073)
at Sidebar.render (LensDev.js:636929)
at allowStateChanges (LensDev.js:334943)
at LensDev.js:333372
at trackDerivedFunction (LensDev.js:334726)
at Reaction../node_modules/mobx/lib/mobx.module.js.Reaction.track (LensDev.js:335760)
with app crash. Something with id?
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.
Upgrade to:
"@k8slens/extensions": "^4.0.0-beta.1",
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.
Adding a url
doesn't help either:
clusterPages = [
{
id: "extension-example",
components: {
Page: () => <ExamplePage extension={this}/>,
}
}
]
clusterPageMenus = [
{
id: this.clusterPages[0].id, // must be the same as in page registration to be visible in sidebar
url: `/${this.clusterPages[0].id}`,
title: "Hello World",
components: {
Icon: ExampleIcon
}
}
]
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.
Ok, probably better to wait fixes from lensapp/lens#1364
"allowSyntheticDefaultImports": true, | ||
"experimentalDecorators": true, | ||
"jsx": "react", | ||
"plugins": [{ "name": "typescript-plugin-css-modules" }], |
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.
Did't know about that field. How does it work? Where the list of available plugins?
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.
Here is the plugin
field documentation https://www.typescriptlang.org/tsconfig#plugins
And here is typescript-plugin-css-modules
page https://github.com/mrmckeb/typescript-plugin-css-modules
padding: calc(var(--padding) * 2); | ||
|
||
// Check if light theme enabled in Lens | ||
.theme-light & { |
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.
probably we should specify top-level theme element more precisely, like body[data-theme="light"]
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.
I'm working on this, changes will be in different PR.
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
@aleksfront I had a quick look. It's great that you're providing these samples, thank you! What I don't see is the theme switching use case. How will developers handle that? How will they know when the theme changes? Right now, all I see are different ways to write CSS that uses theme-based CSS variables -- but maybe I missed something since I didn't look closely at everything. |
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
@ixrock Samples working with latest (beta 3) extension api types. Please re-review. |
Adding 3 sample extensions for different styling modifications. All of them based on
HelloWorld
sample.styling-sass-sample
extension using Sassstyling-emotion-sample
extension using CSS-in-JS Emotionstyling-css-modules-sample
extension using CSS Modules for class name encapsulation