Skip to content

feat: add scss preprocessor in docs && fix:(Toast) single lifeMode bug in Toast #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Message } from '../src/toast.type'
import { Message } from '../toast-types'

export function useToastHelper() {
function severityDelay(msg: Message) {
Expand Down
12 changes: 8 additions & 4 deletions packages/devui-vue/devui/toast/src/toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,25 @@ export default defineComponent({
if (props.lifeMode === 'single') {
setTimeout(() => {
messages.value.forEach((msg, i) => {
timeoutArr[i] = setTimeout(() => singleModeRemove(msg, i), msg.life || severityDelay(msg))
timeoutArr[i] = setTimeout(() => singleModeRemove(msg), msg.life || severityDelay(msg))
})
})
} else {
timeout = setTimeout(() => removeAll(), defaultLife.value)
}
}

function singleModeRemove(msg: Message, i: number) {
function singleModeRemove(msg: Message) {
removeMsgAnimation(msg)
setTimeout(() => {
onCloseEvent(msg)

if (hasMsgAnimation()) {
messages.value.splice(i, 1)
// avoid index confusion in settimeout
const index = messages.value.indexOf(msg)
if (index !== -1) {
messages.value.splice(index, 1)
}
} else {
messages.value = []
}
Expand Down Expand Up @@ -199,7 +203,7 @@ export default defineComponent({
if (props.lifeMode === 'single') {
const msgLife = msg!.life || severityDelay(msg!)
const remainTime = msgLife - (Date.now() - timestamp)
timeoutArr[i!] = setTimeout(() => singleModeRemove(msg!, i!), remainTime)
timeoutArr[i!] = setTimeout(() => singleModeRemove(msg!), remainTime)
} else {
resetDelay(() => removeAll())
}
Expand Down
4 changes: 3 additions & 1 deletion packages/devui-vue/docs/.vitepress/config/markdown.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const markdown = {
config: (md) => {
const { demoBlockPlugin } = require('vitepress-theme-demoblock')
md.use(demoBlockPlugin)
md.use(demoBlockPlugin, {
cssPreprocessor: 'scss'
})
}
}
export default markdown
6 changes: 3 additions & 3 deletions packages/devui-vue/docs/components/card/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</d-card>
</template>
<style lang="scss">
@import '@devui-design/icons/icomoon/devui-icon.css'
@import '@devui-design/icons/icomoon/devui-icon.css';
.card-demo-icon {
cursor: pointer;
font-size: 16px;
Expand Down Expand Up @@ -114,7 +114,7 @@
</d-card>
</template>
<style lang="scss">
@import '@devui-design/icons/icomoon/devui-icon.css'
@import '@devui-design/icons/icomoon/devui-icon.css';
.icon {
cursor: pointer;
font-size: 16px;
Expand Down Expand Up @@ -185,7 +185,7 @@
</d-card>
</template>
<style lang="scss">
@import '@devui-design/icons/icomoon/devui-icon.css'
@import '@devui-design/icons/icomoon/devui-icon.css';
.icon {
cursor: pointer;
font-size: 16px;
Expand Down
4 changes: 3 additions & 1 deletion packages/devui-vue/docs/components/pagination/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ export default defineComponent({
})
</script>

<style>
<style lang="scss">
@import '@devui/styles-var/devui-var.scss';

/* 配置中的每一项,自定义项建议应用此样式或在此基础上修改 */
.pagination-config-item {
padding-bottom: 8px;
Expand Down