Skip to content

Commit

Permalink
chore: small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
surunzi committed Jul 4, 2023
1 parent a488721 commit d3bea3e
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module.exports = wrap(async function (component) {
pkg.peerDependencies = peerDependencies
}
pkg.exports = {
'.': `esm/${component}/index.js`,
'.': `./esm/${component}/index.js`,
'./css': `./luna-${component}.css`,
[`./luna-${component}.css`]: `./luna-${component}.css`,
[`./luna-${component}.js`]: `./luna-${component}.js`,
Expand Down
7 changes: 7 additions & 0 deletions src/toolbar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ import 'luna-toolbar/luna-toolbar.css'
import LunaToolbar from 'luna-toolbar'
```

## Usage

```javascript
const toolbar = new LunaToolbar(container)
toolbar.appendText('Test')
```

## Api

### appendHtml(html: string | HTMLElement): ToolbarHtml
Expand Down
4 changes: 4 additions & 0 deletions src/toolbar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import { exportCjs } from '../share/util'

/**
* Application toolbar.
*
* @example
* const toolbar = new LunaToolbar(container)
* toolbar.appendText('Test')
*/
export default class Toolbar extends Component {
private items: ToolbarItem[] = []
Expand Down
15 changes: 15 additions & 0 deletions src/toolbar/react.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import {
ReactElement,
useState,
} from 'react'
import h from 'licia/h'
import types from 'licia/types'
import Toolbar from './index'
import { createPortal } from 'react-dom'

interface IToolbarProps {}

Expand Down Expand Up @@ -113,4 +115,17 @@ export const LunaToolbarSpace: FC<IToolbarItemProps> = (props) => {
return null
}

export const LunaToolbarHtml: FC<IToolbarItemProps> = (props) => {
const html = useRef(h('div') as HTMLDivElement)
document.createDocumentFragment()

useEffect(() => {
if (props.toolbar) {
props.toolbar.appendHtml(html.current)
}
}, [props.toolbar])

return createPortal(<>{props.children}</>, html.current)
}

export default LunaToolbar
14 changes: 14 additions & 0 deletions src/toolbar/story.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import LunaToolbar, {
LunaToolbarSeparator,
LunaToolbarSpace,
LunaToolbarInput,
LunaToolbarHtml,
} from './react'

const def = story(
Expand Down Expand Up @@ -37,6 +38,9 @@ const def = story(
const filter = toolbar.appendInput('filter', '', 'Filter')
filter.disable()
toolbar.appendSpace()
toolbar.appendHtml(
'<span style="color:green;line-height:30px;">Loading</span>'
)
toolbar.appendText('Status: OK')

return toolbar
Expand All @@ -60,6 +64,16 @@ const def = story(
<LunaToolbarSeparator />
<LunaToolbarInput key="filter" value="" placeholder="Filter" />
<LunaToolbarSpace />
<LunaToolbarHtml>
<span
style={{
color: 'green',
lineHeight: '30px',
}}
>
Loading
</span>
</LunaToolbarHtml>
<LunaToolbarText text="Status: OK" />
</LunaToolbar>
)
Expand Down
2 changes: 2 additions & 0 deletions src/toolbar/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
@include component();
height: 31px;
display: flex;
white-space: nowrap;
overflow-x: hidden;
border-bottom: 1px solid $border-color;
}

Expand Down

0 comments on commit d3bea3e

Please sign in to comment.