UNPKG

roadui

Version:

Sleek, intuitive, and powerful front-end framework for faster and easier web development.

431 lines (356 loc) 8.3 kB
// Name: Modal // // Description: Define style for Modal Plugin // // TODO: 1. 宽度自适应的情况 // 2. 最大高度限制 // 3. 不同屏幕宽度下设置不同大小 // // ============================================================================= // Modal Variables // ============================================================================= @modal-bg-color: #f8f8f8; @modal-btn-color : @global-primary; @modal-btn-bg: @modal-bg-color; @modal-btn-active-bg: #d4d4d4; @modal-duration: 300ms; @modal-border-color: #dedede; @modal-border-radius: @global-radius; @modal-actions-duration: @modal-duration; @modal-actions-btn-bg: rgba(243, 243, 243, 0.95); @modal-actions-active-btn-bg: #dcdcdc; @modal-popup-duration: @modal-duration; @modal-lg: 810px; @modal-md: 540px; @modal-sm: 270px; /* ========================================================================== Component: Modal Plugin ============================================================================ */ .@{ns}modal { width: @modal-sm; position: fixed; display: none; z-index: @z-index-modal; left: 50%; margin-left: -@modal-sm/2; margin-top: 0; top: 50%; text-align: center; border-radius: @modal-border-radius; opacity: 0; // @see https://github.com/amazeui/amazeui/issues/712 // transform: translate3d(0, 0, 0) scale(1.185); transform: scale(1.185); transition-property: transform, opacity; backface-visibility: hidden; perspective: 1000px; &:focus { outline: 0; } &.@{ns}modal-active { opacity: 1; transition-duration: @modal-duration; // transform: translate3d(0, 0, 0) scale(1); transform: scale(1); } &.@{ns}modal-out { opacity: 0; z-index: @z-index-modal - 1; transition-duration: @modal-duration; // transform: translate3d(0, 0, 0) scale(0.815); transform: scale(0.815); } @media @medium-up { width: @modal-md; margin-left: -@modal-md/2; } /*@media @large-up { width: @modal-lg; margin-left: -@modal-lg/2; }*/ .hook-modal; } .@{ns}modal-dialog { border-radius: @modal-border-radius; background: @modal-bg-color; .hook-modal-dialog; } .@{ns}modal-hd { padding: 15px 10px 5px 10px; font-size: 1.8rem; font-weight: 500; + .@{ns}modal-bd { padding-top: 0; } .@{ns}close { position: absolute; top: 4px; right: 4px; } .hook-modal-hd; } .@{ns}modal-bd { padding: 15px 10px; text-align: center; border-bottom: 1px solid @modal-border-color; border-radius: 2px 2px 0 0; // References https://github.com/allmobilize/amazeui/issues/464 // overflow: hidden; + .@{ns}modal-bd { margin-top: 5px; } .hook-modal-hd; } // Prompt input .@{ns}modal-prompt-input { display: block; margin: 5px auto 0 auto; border-radius: @modal-border-radius; padding: 5px; line-height: 1.8rem; width: 80%; border: 1px solid @modal-border-color; -webkit-appearance: none; -moz-appearance: none; -ms-appearance: none; appearance: none; &:focus { outline: none; border-color: darken(@modal-border-color, 3%); } .hook-modal-prompt-input; } .@{ns}modal-footer { height: 44px; overflow: hidden; display: table; width: 100%; border-collapse: collapse; .hook-modal-footer; } .@{ns}modal-btn { display: table-cell!important; padding: 0 5px; height: 44px; box-sizing: border-box !important; font-size: 1.6rem; line-height: 44px; text-align: center; color: @global-primary; .text-overflow(block); cursor: pointer; border-right: 1px solid @modal-border-color; &:first-child { border-radius: 0 0 0 @modal-border-radius; } &:last-child { border-right: none; border-radius: 0 0 @modal-border-radius 0; } &:first-child:last-child { border-radius: 0 0 @modal-border-radius @modal-border-radius; } &.@{ns}modal-btn-bold { font-weight: 500; } &:active { background: @modal-btn-active-bg; } & + .@{ns}modal-btn { border-left: 1px solid @modal-border-color; } .hook-modal-btn; } // without buttons // ----------------------------------------------------------------------------- .@{ns}modal-no-btn { .@{ns}modal-dialog { border-radius: @global-radius; border-bottom: none; } .@{ns}modal-bd { border-bottom: none; } .@{ns}modal-footer { display: none; } .hook-modal-no-btn; } // Loading // ============================================================================= .@{ns}modal-loading { // width: @modal-sm !important; // margin-left: -@modal-sm/2 !important; .@{ns}modal-bd { border-bottom: none; } .@{ns}icon-spin { display: inline-block; font-size: 2.4rem; } .@{ns}modal-footer { display: none; } .hook-modal-loading; } // Modal - Action // ======================================================================== .@{ns}modal-actions { position: fixed; left: 0; bottom: 0; z-index: @z-index-modal; width: 100%; max-height: 100%; overflow-x: hidden; overflow-y: auto; text-align: center; border-radius: @modal-border-radius; transform: translateY(100%); transition: transform @modal-actions-duration; &.@{ns}modal-active { transform: translateY(0); } &.@{ns}modal-out { z-index: @z-index-modal - 1; transform: translateY(100%); } .hook-modal-actions; } .@{ns}modal-actions-group { margin: 10px; .@{ns}list { margin: 0; border-radius: @modal-border-radius; & > li { margin-bottom: 0; border-bottom: none; .text-overflow(); box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.015); & > a { padding: 1rem; .text-overflow(); } &:first-child { border-top: none; .border-top-radius(@modal-border-radius); } &:last-child { border-bottom: none; .border-bottom-radius(@modal-border-radius); } } } } .@{ns}modal-actions-header { padding: 1rem; color: @gray-light; font-size: 1.4rem; } .@{ns}modal-actions-danger { color: @global-danger; a { color: inherit; } } // Modal Popup // ======================================================================== .@{ns}popup { position: fixed; left: 0; top: 0; width: 100%; height: 100%; z-index: @z-index-modal; background: #fff; display: none; overflow: hidden; transition-property: transform; transform: translateY(100%); &.@{ns}modal-active, &.@{ns}modal-out { transition-duration: @modal-popup-duration; } &.@{ns}modal-active { transform: translateY(0); } &.@{ns}modal-out { transform: translateY(100%); } // iPad Modal @media all and (min-width: 630px) and (min-height: 630px) { width: 630px; height: 630px; left: 50%; top: 50%; margin-left: -315px; margin-top: -315px; transform: translateY(1024px); &.@{ns}modal-active { transform: translateY(0); } &.@{ns}modal-out { transform: translateY(1024px); } } .hook-popup; } .@{ns}popup-inner { padding-top: 44px; height: 100%; .scrollable(); .hook-popup-inner; } .@{ns}popup-hd { position: absolute; top: 0; z-index: @global-z-index; width: 100%; height: 43px; border-bottom: 1px solid @modal-border-color; background-color: #fff; .@{ns}popup-title { font-size: 1.8rem; font-weight: bold; line-height: 43px; text-align: center; margin: 0 30px; color: @gray-dark; .text-overflow(); } .@{ns}close { position: absolute; right: 10px; top: 8px; cursor: pointer; transition: all 0.3s; color: @gray-light; &:hover { transform: rotate(360deg); color: @gray; } } .hook-popup-hd; } .@{ns}popup-bd { padding: 15px; background: #f8f8f8; color: @gray; .hook-popup-bd; } // Hooks // ============================================================================= .hook-modal() {} .hook-modal-hd() {} .hook-modal-bd() {} .hook-modal-footer() {} .hook-modal-dialog() {} .hook-modal-prompt-input() {} .hook-modal-btn() {} .hook-modal-no-btn() {} .hook-modal-loading() {} .hook-modal-actions() {} .hook-popup() {} .hook-popup-inner() {} .hook-popup-hd() {} .hook-popup-bd() {}