Skip to content

Commit

Permalink
plugins: Show how to use styles inside a plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
illume authored and joaquimrocha committed Apr 20, 2022
1 parent ac773fd commit b7ba608
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions plugins/examples/pod-counter/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
import React from 'react';
import { Headlamp, Plugin, Registry, K8s } from '@kinvolk/headlamp-plugin/lib';
import { Headlamp, K8s, Plugin, Registry } from '@kinvolk/headlamp-plugin/lib';
import { Typography } from '@material-ui/core';

import { makeStyles } from '@material-ui/styles';
import React from 'react';
// import { SectionBox } from '@kinvolk/headlamp-plugin/lib/CommonComponents';

const useStyle = makeStyles(() => ({
pods: {
fontStyle: 'italic',
},
}));

function PodCounter() {
const classes = useStyle();
const [pods, error] = K8s.ResourceClasses.Pod.useList();
const msg = pods === null ? 'Loading…' : pods.length.toString();

return (
<Typography color="textPrimary">{!error ? `# Pods: ${msg}` : 'Uh, pods!?'}</Typography>
<Typography color="textPrimary" className={classes.pods}>
{!error ? `# Pods: ${msg}` : 'Uh, pods!?'}
</Typography>
);
}

class PodCounterPlugin extends Plugin {
initialize(registry: Registry) {
registry.registerAppBarAction('pod-counter-action', () =>
<PodCounter />
);

registry.registerAppBarAction('pod-counter-action', () => <PodCounter />);
return true;
}
}
Expand Down

0 comments on commit b7ba608

Please sign in to comment.