Skip to content

Commit

Permalink
🐛 fix: try to fix header bug #46
Browse files Browse the repository at this point in the history
  • Loading branch information
canisminor1990 committed Apr 22, 2023
1 parent 894aec6 commit afdbe53
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 59 deletions.
6 changes: 2 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@

## [1.6.1](https://github.com/canisminor1990/sd-web-ui-kitchen-theme/compare/v1.6.0...v1.6.1) (2023-04-22)


### 🐛 Bug Fixes

* fix typo ([9faf33e](https://github.com/canisminor1990/sd-web-ui-kitchen-theme/commit/9faf33e))
- fix typo ([9faf33e](https://github.com/canisminor1990/sd-web-ui-kitchen-theme/commit/9faf33e))

# [1.6.0](https://github.com/canisminor1990/sd-web-ui-kitchen-theme/compare/v1.5.2...v1.6.0) (2023-04-22)


### ✨ Features

* add setting panel ([f2beaaa](https://github.com/canisminor1990/sd-web-ui-kitchen-theme/commit/f2beaaa)), closes [#44](https://github.com/canisminor1990/sd-web-ui-kitchen-theme/issues/44)
- add setting panel ([f2beaaa](https://github.com/canisminor1990/sd-web-ui-kitchen-theme/commit/f2beaaa)), closes [#44](https://github.com/canisminor1990/sd-web-ui-kitchen-theme/issues/44)

## [1.5.2](https://github.com/canisminor1990/sd-web-ui-kitchen-theme/compare/v1.5.1...v1.5.2) (2023-04-22)

Expand Down
1 change: 1 addition & 0 deletions README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ http://localhost:7860/?__theme=dark
## ⚒️ 推荐设置

Kitchen WebUI Setting

> 右上角 ⚙ 图标打开设置面板,当前可用设置如下
- Sidebar default width (快捷设置侧边栏默认宽度): 280
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ http://localhost:7860/?__theme=dark
## ⚒️ Recommended Settings

Kitchen WebUI Setting

> top right ⚙ icon in header
- Sidebar default width: 280
Expand Down
96 changes: 48 additions & 48 deletions javascript/index.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/components/DraggablePanel/DraggablePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export interface DraggablePanelProps {
* 类名前缀
*/
prefixCls?: string
maxHeight?: boolean
}

export const Draggable: FC<DraggablePanelProps> = memo(
Expand All @@ -114,6 +115,7 @@ export const Draggable: FC<DraggablePanelProps> = memo(
expandable = true,
isExpand,
onExpandChange,
maxHeight,
}) => {
const prefixCls = 'draggable-panel'

Expand All @@ -138,6 +140,7 @@ export const Draggable: FC<DraggablePanelProps> = memo(
className={className}
placement={placement}
style={style}
maxHeight={maxHeight}
>
{children}
</FixMode>
Expand Down
4 changes: 3 additions & 1 deletion src/components/DraggablePanel/FixMode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export interface FixModePanelProps {
* 类名前缀
*/
prefixCls?: string
maxHeight?: boolean
}

const DEFAULT_HEIGHT = 150
Expand Down Expand Up @@ -128,12 +129,13 @@ export const FixMode: FC<FixModePanelProps> = memo<FixModePanelProps>(
isExpand: expand,
onExpandChange,
className,
maxHeight,
}) => {
const prefixCls = 'draggable-panel'

const isVertical = placement === 'top' || placement === 'bottom'

const { styles, cx } = useStyle(prefixCls)
const { styles, cx } = useStyle({ prefix: prefixCls, maxHeight })

const [isExpand, setIsExpand] = useControlledState(true, {
value: expand,
Expand Down
2 changes: 1 addition & 1 deletion src/components/DraggablePanel/FloatMode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const FloatMode: FC<FloatProps> = memo(
prefixCls,
canResizing,
}) => {
const { styles } = useStyle(prefixCls)
const { styles } = useStyle({ prefix: prefixCls, maxHeight: false })

const resizeHandleClassNames: HandleClassName = useMemo(() => {
if (!canResizing) return {}
Expand Down
5 changes: 3 additions & 2 deletions src/components/DraggablePanel/style.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { createStyles, css, cx } from 'antd-style'
import { rgba } from 'polished'

export const useStyle = createStyles(({ token }, prefix: string) => {
export const useStyle = createStyles(({ token }, props: { prefix?: string; maxHeight?: boolean }) => {
const { prefix, maxHeight } = props
const commonHandle = css`
position: relative;
&::before {
Expand Down Expand Up @@ -117,7 +118,7 @@ export const useStyle = createStyles(({ token }, prefix: string) => {
backdrop-filter: blur(40px);
overflow: hidden;
position: relative;
height: 100% !important;
${maxHeight ? 'height: 100% !important;' : ''}
`
),
float: cx(
Expand Down
1 change: 1 addition & 0 deletions src/components/ExtraNetworkSidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const Sidebar: React.FC<SidebarProps> = ({ children, style }) => {
<>
<GlobalStyle />
<DraggablePanel
maxHeight
style={style}
placement="right"
defaultSize={{ width: setting.extraNetworkSidebarWidth }}
Expand Down
6 changes: 3 additions & 3 deletions src/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ interface HeaderProps {

const Header: React.FC<HeaderProps> = ({ children, themeMode }) => {
const { mobile } = useResponsive()
const [expand, setExpand] = useState<boolean>(!mobile)
const [expand, setExpand] = useState<boolean>(true)
const handleSetTheme = useCallback(() => {
const theme = themeMode === 'light' ? 'dark' : 'light'
const gradioURL = qs.parseUrl(window.location.href)
Expand All @@ -66,8 +66,8 @@ const Header: React.FC<HeaderProps> = ({ children, themeMode }) => {
}, [themeMode])

useEffect(() => {
setExpand(!mobile)
}, [mobile])
if (mobile) setExpand(false)
}, [])

return (
<DraggablePanel placement="top" defaultSize={{ height: 'auto' }} isExpand={expand} onExpandChange={setExpand}>
Expand Down
1 change: 1 addition & 0 deletions src/components/Sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const Sidebar: React.FC<SidebarProps> = ({ children, loading, style }) => {

return (
<DraggablePanel
maxHeight
style={style}
placement="left"
defaultSize={{ width: setting.sidebarWidth }}
Expand Down

0 comments on commit afdbe53

Please sign in to comment.