diff --git a/packages/common/style/var.less b/packages/common/style/var.less index 1f5aa397..26186edc 100644 --- a/packages/common/style/var.less +++ b/packages/common/style/var.less @@ -41,3 +41,17 @@ @notify-padding: 6px 15px; @notify-font-size: 14px; @notify-line-height: 20px; + +// Toast +@toast-max-width: 70%; +@toast-font-size: 14px; +@toast-text-color: @white; +@toast-line-height: 20px; +@toast-border-radius: 4px; +@toast-background-color: rgba(0, 0, 0, .7); +@toast-icon-size: 50px; +@toast-text-min-width: 96px; +@toast-text-padding: 8px 12px; +@toast-default-padding: 15px; +@toast-default-width: 90px; +@toast-default-min-height: 90px; diff --git a/packages/toast/index.less b/packages/toast/index.less index 5a5ea528..4f03188f 100644 --- a/packages/toast/index.less +++ b/packages/toast/index.less @@ -2,44 +2,42 @@ .van-toast { display: flex; - color: @white; - font-size: 14px; - line-height: 20px; - border-radius: 4px; + color: @toast-text-color; + font-size: @toast-font-size; + line-height: @toast-line-height; + border-radius: @toast-border-radius; word-break: break-all; align-items: center; - justify-content: center; flex-direction: column; - box-sizing: border-box; - background-color: rgba(0, 0, 0, .7); + justify-content: center; + box-sizing: content-box; + background-color: @toast-background-color; &__container { + position: fixed; top: 50%; left: 50%; - max-width: 80%; - position: fixed; + max-width: @toast-max-width; // hack for avoid max-width when use left & fixed width: fit-content; transform: translate(-50%, -50%); } &--text { - min-width: 120px; - padding: 8px 12px; + padding: @toast-text-padding; + min-width: @toast-text-min-width; } &--icon { - width: 120px; - min-height: 120px; - padding: 15px; + width: @toast-default-width; + padding: @toast-default-padding; + min-height: @toast-default-min-height; .van-toast__icon { - height: 1em; - font-size: 50px; + font-size: @toast-icon-size; } .van-toast__text { - font-size: 14px; padding-top: 10px; } }