> = (props) => {
return () => toolbar.current?.destroy()
}, [])
+ useEffect(() => {
+ if (toolbar.current) {
+ toolbar.current.setOption('theme', props.theme)
+ }
+ }, [props.theme])
+
return (
{Children.map(props.children, (child) => {
@@ -77,8 +85,9 @@ export const LunaToolbarText: FC = (props) => {
}
interface IToolbarButtonProps extends IToolbarItemProps {
- title: string
+ content: string | HTMLElement
onClick: () => void
+ state?: IButtonState
}
export const LunaToolbarButton: FC = (props) => {
@@ -87,14 +96,21 @@ export const LunaToolbarButton: FC = (props) => {
useEffect(() => {
if (props.toolbar) {
toolbarButton.current = props.toolbar.appendButton(
- props.title,
- props.onClick
+ props.content,
+ props.onClick,
+ props.state
)
}
return () => toolbarButton.current?.detach()
}, [props.toolbar])
+ useEffect(() => {
+ if (toolbarButton.current && props.state) {
+ toolbarButton.current.setState(props.state)
+ }
+ }, [props.state])
+
return null
}
diff --git a/src/toolbar/story.js b/src/toolbar/story.js
index 8829002..faa49f8 100644
--- a/src/toolbar/story.js
+++ b/src/toolbar/story.js
@@ -39,9 +39,13 @@ const def = story(
const filter = toolbar.appendInput('filter', '', 'Filter')
filter.disable()
- toolbar.appendButton('Trigger', () => {
- console.log('trigger')
- })
+ toolbar.appendButton(
+ 'Trigger',
+ () => {
+ console.log('trigger')
+ },
+ 'hover'
+ )
toolbar.appendText('Size:')
toolbar.appendNumber('size', 50, {
@@ -61,12 +65,13 @@ const def = story(
{
readme,
source: __STORY__,
- ReactComponent() {
+ ReactComponent({ theme }) {
return (
{
console.log(key, val, oldVal)
}}
+ theme={theme}
>
console.log('trigger')}
+ state="hover"
/>
diff --git a/src/toolbar/style.scss b/src/toolbar/style.scss
index 6b437af..3ddf8ee 100644
--- a/src/toolbar/style.scss
+++ b/src/toolbar/style.scss
@@ -57,11 +57,23 @@
.item-button {
button {
- @include button();
color: $color-text;
height: 22px;
margin-top: 4px;
margin-bottom: 4px;
+ border: none;
+ background: transparent;
+ border: 1px solid transparent;
+ border-radius: #{$border-radius-x-s}px;
+ &:hover,
+ &.hover {
+ background: $color-fill-tertiary;
+ border-color: $color-border;
+ }
+ &:active,
+ &.active {
+ background: $color-fill-secondary;
+ }
}
}
@@ -81,8 +93,16 @@
}
.item-button {
button {
- @include button(true);
color: $color-text-dark;
+ &:hover,
+ &.hover {
+ background: $color-fill-secondary-dark;
+ border-color: $color-border-dark;
+ }
+ &:active,
+ &.active {
+ background: $color-fill-tertiary-dark;
+ }
}
}
.item-select {