Skip to content
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: weather widget plugin #21

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"vite-plugin-imp": "^2.4.0",
"vite-plugin-node-polyfills": "^0.22.0",
"vite-plugin-progress": "^0.0.7",
"vite-plugin-stylelint": "^5.3.1"
"vite-plugin-stylelint": "^5.3.1",
"vite-plugin-svg-icons": "^2.0.1"
},
"browserslist": {
"production": [
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export { default as Tooltip } from './tooltip';
export { default as DateRangePicker } from './date-range-picker';
export { default as RouteLoadingIndicator } from './route-loading-indicator';
export { default as Empty } from './empty';
export { default as SvgIcon } from './svg-icon';
21 changes: 21 additions & 0 deletions apps/web/src/components/svg-icon/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';

export interface SvgIconProps extends React.SVGProps<SVGSVGElement> {
name: string;
prefix?: string;
color?: string;
}

const SvgIcon: React.FC<SvgIconProps> = props => {
const { name, prefix = 'icon', color = 'currentColor', ...restProps } = props;

const symbolId = `#${prefix}-${name}`;

return (
<svg {...restProps} aria-hidden="true">
<use href={symbolId} fill={color} />
</svg>
);
};

export default SvgIcon;
1 change: 1 addition & 0 deletions apps/web/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { createBrowserRouter, RouterProvider } from 'react-router-dom';
import { i18n, theme } from '@milesight/shared/src/services';
import routes from '@/routes';
import '@/styles/index.less';
import 'virtual:svg-icons-register';

const router = createBrowserRouter(routes, { basename: '/' });
const root = createRoot(document.getElementById('root')!);
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/plugin/config-plugin/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
flex-direction: column;
align-items: center;
justify-content: center;
max-width: calc(100% - 400px);
padding: @padding-xl;
background-color: var(--gray-color-2);
border: @border-base;
Expand Down
49 changes: 49 additions & 0 deletions apps/web/src/plugin/plugins/weather-widget/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"type": "weatherWidget",
"name": "Weather Widget",
"class": "operate",
"icon": "./icon.png",
"defaultRow": 6,
"defaultCol": 8,
"minRow": 4,
"minCol": 4,
"configProps": [
{
"style": "width: 100%",
"components": [
{
"type": "entitySelect",
"title": "Entity",
"key": "entity",
"style": "width: 100%",
"getDataUrl": "",
"componentProps": {
"size": "small",
"entityType": ["SERVICE"],
"entityExcludeChildren": true
},
"rules": {
"required": true
}
}
]
},
{
"components": [
{
"type": "input",
"title": "Title",
"key": "title",
"defaultValue": "Title",
"componentProps": {
"size": "small",
"inputProps": {
"maxLength": 35
}
}
}
]
}
],
"view": []
}
29 changes: 29 additions & 0 deletions apps/web/src/plugin/plugins/weather-widget/configure/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { forwardRef } from 'react';
import { RenderConfig } from '../../../render';

interface ConfigPluginProps {
config: CustomComponentProps;
value: any;
onOk: (data: any) => void;
onChange: (data: any) => void;
}

const Plugin = forwardRef((props: ConfigPluginProps, ref: any) => {
const { onOk, onChange, value, config } = props;

const handleSubmit = (data: any) => {
onOk(data);
};

return (
<RenderConfig
config={config}
onOk={handleSubmit}
ref={ref}
onChange={onChange}
value={value}
/>
);
});

export default Plugin;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading