Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pro-layout
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
packages
pro-layout
Commits
093f3382
Commit
093f3382
authored
Oct 22, 2020
by
eth3lbert
Committed by
言肆
Oct 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add FooterToolbar
parent
c1f17791
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
185 additions
and
9 deletions
+185
-9
footer-toolbar.html
examples/footer-toolbar.html
+0
-0
footer-toolbar.tsx
examples/footer-toolbar.tsx
+108
-0
index.tsx
src/FooterToolbar/index.tsx
+75
-7
index.tsx
src/ProProvider/index.tsx
+2
-2
No files found.
examples/footer-toolbar.html
0 → 100644
View file @
093f3382
examples/footer-toolbar.tsx
0 → 100644
View file @
093f3382
import
{
Button
,
Card
,
Space
,
Switch
}
from
'ant-design-vue'
;
import
'ant-design-vue/dist/antd.less'
;
import
{
createApp
,
reactive
}
from
'vue'
;
import
FooterToolbar
,
{
IFooterToolbarProps
}
from
'../src/FooterToolbar'
;
import
{
createRouteContext
}
from
'../src/RouteContext'
;
const
DemoComponent
=
{
setup
()
{
const
state
=
reactive
({
name
:
'value'
,
hasFooterToolbar
:
'unset'
as
string
|
boolean
,
toolbarProps
:
{}
as
IFooterToolbarProps
,
});
const
setToolbarProps
=
tProps
=>
{
state
.
toolbarProps
=
{
...
state
.
toolbarProps
,
...
tProps
};
};
const
{
state
:
routeContext
,
provider
:
RouteContextProvider
}
=
createRouteContext
({
hasFooterToolbar
:
false
,
setHasFooterToolbar
:
v
=>
{
state
.
hasFooterToolbar
=
v
;
routeContext
.
hasFooterToolbar
=
v
;
},
});
return
()
=>
(
<
div
class=
"components"
>
<
h2
>
# Template
</
h2
>
<
Card
style=
{
{
marginBottom
:
'24px'
,
background
:
'rgb(244,244,244)'
}
}
>
<
Space
size=
"middle"
>
<
Button
type=
"primary"
onClick=
{
()
=>
{
state
.
name
=
new
Date
().
getTime
().
toString
();
routeContext
.
setHasFooterToolbar
(
!
routeContext
.
hasFooterToolbar
);
}
}
>
{
!
routeContext
.
hasFooterToolbar
?
'Open'
:
'Close'
}
</
Button
>
<
Switch
checkedChildren=
"w/ extra"
unCheckedChildren=
"w/o extra"
checked=
{
!!
state
.
toolbarProps
.
extra
}
onClick=
{
()
=>
{
state
.
name
=
new
Date
().
getTime
().
toString
();
const
extra
=
!
state
.
toolbarProps
.
extra
?
(
<
img
src=
"https://gw.alipayobjects.com/zos/antfincdn/PmY%24TNNDBI/logo.svg"
alt=
"logo"
width=
"32"
height=
"32"
/>
)
:
(
undefined
);
setToolbarProps
({
extra
});
}
}
/>
<
Switch
checkedChildren=
"w/ renderContent"
unCheckedChildren=
"w/o renderContent"
checked=
{
!!
state
.
toolbarProps
.
renderContent
}
onClick=
{
()
=>
{
state
.
name
=
new
Date
().
getTime
().
toString
();
const
renderContent
=
!
state
.
toolbarProps
.
renderContent
?
()
=>
'home_toolbar'
:
undefined
;
setToolbarProps
({
renderContent
});
}
}
/>
</
Space
>
<
div
style=
{
{
margin
:
'12px 0'
}
}
>
state
<
pre
>
{
JSON
.
stringify
(
{
name
:
state
.
name
,
toolbarProps
:
Object
.
fromEntries
(
Object
.
entries
(
state
.
toolbarProps
).
map
(([
k
,
v
])
=>
[
k
,
typeof
v
]),
),
},
null
,
2
,
)
}
</
pre
>
routeContext:
<
pre
>
{
JSON
.
stringify
(
routeContext
,
null
,
2
)
}
</
pre
>
</
div
>
</
Card
>
<
div
>
<
RouteContextProvider
>
{
routeContext
.
hasFooterToolbar
&&
(
<
FooterToolbar
{
...
state
.
toolbarProps
}
>
<
button
key=
"button"
type=
"button"
>
right
</
button
>
</
FooterToolbar
>
)
}
</
RouteContextProvider
>
</
div
>
</
div
>
);
},
};
const
app
=
createApp
(
DemoComponent
);
app
.
mount
(
'#__vue-content>div'
);
src/FooterToolbar/index.tsx
View file @
093f3382
import
{
VNodeChild
}
from
'vue'
;
import
{
computed
,
defineComponent
,
inject
,
onBeforeUnmount
,
onMounted
,
PropType
,
VNodeChild
,
}
from
'vue'
;
import
{
defaultProProviderProps
,
injectProConfigKey
}
from
'../ProProvider'
;
import
{
RouteContextProps
,
useRouteContext
}
from
'../RouteContext'
;
import
'./index.less'
;
import
'./index.less'
;
export
interface
FooterToolbarProps
{
export
interface
I
FooterToolbarProps
{
extra
?:
VNodeChild
;
extra
?:
VNodeChild
|
JSX
.
Element
;
renderContent
?:
(
renderContent
?:
(
props
:
FooterToolbar
Props
&
{
leftWidth
?:
string
},
props
:
this
&
RouteContext
Props
&
{
leftWidth
?:
string
},
dom
:
JSX
.
Element
,
dom
:
JSX
.
Element
,
)
=>
VNodeChild
|
JSX
.
Element
;
)
=>
VNodeChild
|
JSX
.
Element
;
prefixCls
?:
string
;
prefixCls
?:
string
;
}
}
const
FooterToolbar
=
(
props
,
context
)
=>
{
const
FooterToolbarProps
=
{
const
baseClassName
=
`
${
props
.
prefixCls
}
-footer-bar`
;
extra
:
{
type
:
Object
as
PropType
<
VNodeChild
>
},
}
renderContent
:
{
type
:
Function
as
PropType
<
IFooterToolbarProps
[
'renderContent'
]
>
,
},
prefixCls
:
{
type
:
String
as
PropType
<
string
>
},
};
const
FooterToolbar
=
defineComponent
({
name
:
'FooterToolbar'
,
props
:
FooterToolbarProps
,
setup
(
props
,
{
slots
})
{
const
{
getPrefixCls
}
=
inject
(
injectProConfigKey
,
defaultProProviderProps
);
const
prefixCls
=
props
.
prefixCls
||
getPrefixCls
();
const
baseClassName
=
`
${
prefixCls
}
-footer-bar`
;
const
routeContext
=
useRouteContext
();
const
width
=
computed
(()
=>
{
const
{
hasSideMenu
,
isMobile
,
sideWidth
}
=
routeContext
;
if
(
!
hasSideMenu
)
{
return
undefined
;
}
if
(
!
sideWidth
)
{
return
'100%'
;
}
return
isMobile
?
'100%'
:
`calc(100% -
${
sideWidth
}
px)`
;
});
const
dom
=
()
=>
{
return
(
<>
<
div
class=
{
`${baseClassName}-left`
}
>
{
props
.
extra
}
</
div
>
<
div
class=
{
`${baseClassName}-right`
}
>
{
slots
.
default
()
}
</
div
>
</>
);
};
onMounted
(()
=>
{
routeContext
.
setHasFooterToolbar
&&
routeContext
.
setHasFooterToolbar
(
true
);
});
onBeforeUnmount
(()
=>
{
routeContext
.
setHasFooterToolbar
&&
routeContext
.
setHasFooterToolbar
(
false
);
});
return
()
=>
(
<
div
class=
{
baseClassName
}
style=
{
{
width
:
width
.
value
}
}
>
{
props
.
renderContent
?
props
.
renderContent
(
{
...
props
,
...
routeContext
,
leftWidth
:
width
.
value
,
},
dom
(),
)
:
dom
()
}
</
div
>
);
},
});
export
default
FooterToolbar
;
src/ProProvider/index.tsx
View file @
093f3382
import
{
defineComponent
,
reactive
,
toRefs
,
Ref
,
InjectionKey
,
provide
,
SetupContext
,
App
,
PropType
}
from
'vue'
;
import
{
App
,
defineComponent
,
InjectionKey
,
PropType
,
provide
,
reactive
,
SetupContext
,
toRefs
}
from
'vue'
;
import
{
ContentWidth
}
from
'../typings'
;
import
{
ContentWidth
}
from
'../typings'
;
export
const
defaultPrefixCls
=
'ant-pro'
;
export
const
defaultPrefixCls
=
'ant-pro'
;
...
@@ -12,7 +12,7 @@ export interface ProProviderData {
...
@@ -12,7 +12,7 @@ export interface ProProviderData {
export
const
defaultProProviderProps
:
ProProviderData
=
{
export
const
defaultProProviderProps
:
ProProviderData
=
{
getPrefixCls
:
(
suffixCls
?:
string
,
customizePrefixCls
?:
string
)
=>
{
getPrefixCls
:
(
suffixCls
?:
string
,
customizePrefixCls
?:
string
)
=>
{
if
(
customizePrefixCls
)
return
customizePrefixCls
;
if
(
customizePrefixCls
)
return
customizePrefixCls
;
return
`
${
defaultPrefixCls
}
-
${
suffixCls
}
`
;
return
suffixCls
?
`
${
defaultPrefixCls
}
-
${
suffixCls
}
`
:
defaultPrefixCls
;
},
},
i18n
:
(
t
:
string
):
string
=>
t
,
i18n
:
(
t
:
string
):
string
=>
t
,
contentWidth
:
'Fluid'
,
contentWidth
:
'Fluid'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment