dumi-theme-nocobase
Version:
<h1 align="center">dumi-theme-nocobase</h1>
47 lines • 1.66 kB
JavaScript
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import { FloatButton } from 'antd';
import { CompactTheme, DarkTheme } from 'antd-token-previewer/es/icons';
import { FormattedMessage } from 'dumi';
import React from 'react';
import ThemeIcon from "./ThemeIcon";
import { jsx as ___EmotionJSX } from "@emotion/react";
var ThemeSwitch = function ThemeSwitch(props) {
var _props$value = props.value,
value = _props$value === void 0 ? ['light'] : _props$value,
onChange = props.onChange;
return ___EmotionJSX(FloatButton.Group, {
trigger: "click",
icon: ___EmotionJSX(ThemeIcon, null)
}, ___EmotionJSX(FloatButton, {
icon: ___EmotionJSX(DarkTheme, null),
type: value.includes('dark') ? 'primary' : 'default',
onClick: function onClick() {
if (value.includes('dark')) {
onChange(value.filter(function (theme) {
return theme !== 'dark';
}));
} else {
onChange([].concat(_toConsumableArray(value), ['dark']));
}
},
tooltip: ___EmotionJSX(FormattedMessage, {
id: "app.theme.switch.dark"
})
}), ___EmotionJSX(FloatButton, {
icon: ___EmotionJSX(CompactTheme, null),
type: value.includes('compact') ? 'primary' : 'default',
onClick: function onClick() {
if (value.includes('compact')) {
onChange(value.filter(function (theme) {
return theme !== 'compact';
}));
} else {
onChange([].concat(_toConsumableArray(value), ['compact']));
}
},
tooltip: ___EmotionJSX(FormattedMessage, {
id: "app.theme.switch.compact"
})
}));
};
export default ThemeSwitch;