WeUI:專爲微信設計的 UI 庫

WeUI 是由微信官方設計團隊專爲微信移動 Web 應用設計的 UI 庫。javascript

WeUI 是一套同微信原生視覺體驗一致的基礎樣式庫,爲微信 Web 開發量身設計,能夠令用戶的使用感知更加統一。包含buttoncelldialogtoastarticleicon等各式元素。java

使用

方法一:

使用bower進行安裝git

?github

1web

bower install --save weuinpm

方法二:

使用npm進行安裝gulp

?瀏覽器

1服務器

npm install --save weui微信

開發

?

1

2

3

4

5

git clone https://github.com/weui/weui.git

cd weui

npm install -g gulp

npm install

gulp -ws

運行gulp -ws命令,會監聽src目錄下全部文件的變動,而且默認會在8080端口啓動服務器,而後在瀏覽器打開http://localhost:8080/example

手機預覽

請用微信掃碼

 

預覽地址:http://weui.github.io/weui/

GitHub 下載地址:https://github.com/weui/weui

 

Button

按鈕可使用a或者button標籤。wap上要觸發按鈕的active態,必須觸發ontouchstart事件,能夠在body上加上ontouchstart=""全局觸發。

按鈕常見的操做場景:肯定、取消、警示,分別對應class:weui_btn_primaryweui_btn_defaultweui_btn_warn,每種場景都有本身的置灰態weui_btn_disabled,除此外還有一種鏤空按鈕weui_btn_plain_xxx,客戶端webview裏的按鈕尺寸有兩類,默認寬度100%,小型按鈕寬度自適應,兩邊邊框與文本間距0.75em:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

<a href="javascript:;" class="weui_btn weui_btn_primary">按鈕</a>

<a href="javascript:;" class="weui_btn weui_btn_disabled weui_btn_primary">按鈕</a>

<a href="javascript:;" class="weui_btn weui_btn_warn">確認</a>

<a href="javascript:;" class="weui_btn weui_btn_disabled weui_btn_warn">確認</a>

<a href="javascript:;" class="weui_btn weui_btn_default">按鈕</a>

<a href="javascript:;" class="weui_btn weui_btn_disabled weui_btn_default">按鈕</a>

<div class="button_sp_area">

    <a href="javascript:;" class="weui_btn weui_btn_plain_default">按鈕</a>

    <a href="javascript:;" class="weui_btn weui_btn_plain_primary">按鈕</a>

 

    <a href="javascript:;" class="weui_btn weui_btn_mini weui_btn_primary">按鈕</a>

    <a href="javascript:;" class="weui_btn weui_btn_mini weui_btn_default">按鈕</a>

</div>

Cell

Cell,列表視圖,用於將信息以列表的結構顯示在頁面上,是wap上最經常使用的內容結構。Cell由多個section組成,每一個section包括section headerweui_cells_title以及cellsweui_cells

cell由thumnailweui_cell_hd、bodyweui_cell_bd、accessoryweui_cell_ft三部分組成,cell採用自適應佈局,在須要自適應的部分加上classweui_cell_primary便可:

帶說明的列表項

?

1

2

3

4

5

6

7

8

9

10

11

<div class="weui_cells_title">帶說明的列表項</div>

<div class="weui_cells">

    <div class="weui_cell">

        <div class="weui_cell_bd weui_cell_primary">

            <p>標題文字</p>

        </div>

        <div class="weui_cell_ft">

            說明文字

        </div>

    </div>

</div>

Cell可根據須要進行各類自定義擴展,包括輔助說明、跳轉、單選、複選等。下面以帶圖標、說明、跳轉的列表項,其餘狀況能夠直接參考example下的代碼:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

<div class="weui_cells_title">帶圖標、說明、跳轉的列表項</div>

<div class="weui_cells weui_cells_access">

 

    <a class="weui_cell" href="javascript:;">

        <div class="weui_cell_hd">

            <img src="" alt="icon" style="width:20px;margin-right:5px;display:block">

        </div>

        <div class="weui_cell_bd weui_cell_primary">

            <p>cell standard</p>

        </div>

        <div class="weui_cell_ft">

            說明文字

        </div>

    </a>

    <a class="weui_cell" href="javascript:;">

        <div class="weui_cell_hd">

            <img src="" alt="icon" style="width:20px;margin-right:5px;display:block">

        </div>

        <div class="weui_cell_bd weui_cell_primary">

            <p>cell standard</p>

        </div>

        <div class="weui_cell_ft">

            說明文字

        </div>

    </a>

</div>

Dialog

若系統的alert窗體沒法知足網頁的臨時視圖內容需求,則能夠自定義實現與alert形式類似的dialog,而且在dialog中能夠自定義地使用各類控件,來知足需求。

?

1

2

3

4

5

6

7

8

9

10

11

<div class="weui_dialog_confirm">

    <div class="weui_mask"></div>

    <div class="weui_dialog">

        <div class="weui_dialog_hd"><strong class="weui_dialog_title">彈窗標題</strong></div>

        <div class="weui_dialog_bd">自定義彈窗內容<br>...</div>

        <div class="weui_dialog_ft">

            <a href="javascript:;" class="weui_btn_dialog default">取消</a>

            <a href="javascript:;" class="weui_btn_dialog primary">肯定</a>

        </div>

    </div>

</div>

?

1

2

3

4

5

6

7

8

9

10

<div class="weui_dialog_alert">

    <div class="weui_mask"></div>

    <div class="weui_dialog">

        <div class="weui_dialog_hd"><strong class="weui_dialog_title">彈窗標題</strong></div>

        <div class="weui_dialog_bd">彈窗內容,告知當前頁面信息等</div>

        <div class="weui_dialog_ft">

            <a href="javascript:;" class="weui_btn_dialog primary">肯定</a>

        </div>

    </div>

</div>

Toast

toast用於臨時顯示某些信息,而且會在數秒後自動消失。這些信息一般是輕量級操做的成功、失敗或等待狀態信息。

?

1

2

3

4

5

6

7

<div id="toast" style="display: none;">

    <div class="weui_mask_transparent"></div>

    <div class="weui_toast">

        <i class="weui_icon_toast"></i>

        <p class="weui_toast_content">已完成</p>

    </div>

</div>

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

<div id="loadingToast" class="weui_loading_toast" style="display:none;">

    <div class="weui_mask_transparent"></div>

    <div class="weui_toast">

        <div class="weui_loading">            <!-- :) -->

            <div class="weui_loading_leaf weui_loading_leaf_0"></div>

            <div class="weui_loading_leaf weui_loading_leaf_1"></div>

            <div class="weui_loading_leaf weui_loading_leaf_2"></div>

            <div class="weui_loading_leaf weui_loading_leaf_3"></div>

            <div class="weui_loading_leaf weui_loading_leaf_4"></div>

            <div class="weui_loading_leaf weui_loading_leaf_5"></div>

            <div class="weui_loading_leaf weui_loading_leaf_6"></div>

            <div class="weui_loading_leaf weui_loading_leaf_7"></div>

            <div class="weui_loading_leaf weui_loading_leaf_8"></div>

            <div class="weui_loading_leaf weui_loading_leaf_9"></div>

            <div class="weui_loading_leaf weui_loading_leaf_10"></div>

            <div class="weui_loading_leaf weui_loading_leaf_11"></div>

        </div>

        <p class="weui_toast_content">數據加載中</p>

    </div>

</div>

Msg Page

結果頁一般來講能夠認爲進行一系列操做步驟後,做爲流程結束的總結性頁面。結果頁的做用主要是告知用戶操做處理結果以及必要的相關細節(可用於確認 以前的操做是否有誤)等信息;若該流程用於開啓或關閉某些重要功能,可在結果頁增長與該功能相關的描述性內容;除此以外,結果頁也能夠承載一些附加價值操 做,例如提供抽獎、關注公衆號等功能入口。

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

<div class="weui_msg">

    <div class="weui_icon_area"><i class="weui_icon_success weui_icon_msg"></i></div>

    <div class="weui_text_area">

        <h2 class="weui_msg_title">操做成功</h2>

        <p class="weui_msg_desc">內容詳情,可根據實際須要安排</p>

    </div>

    <div class="weui_opr_area">

        <p class="weui_btn_area">

            <a href="javascript:;" class="weui_btn weui_btn_primary">肯定</a>

            <a href="javascript:;" class="weui_btn weui_btn_default">取消</a>

        </p>

    </div>

    <div class="weui_extra_area">

        <a href="">查看詳情</a>

    </div>

</div>

Article

文字視圖顯示大段文字,這些文字一般是頁面上的主體內容。Article支持分段、多層標題、引用、內嵌圖片、有/無序列表等富文本樣式,並可響應用戶的選擇操做。

在微信客戶端webview中使用Article,必須保證文字有足夠的可讀性和可辨識性、使用規範字體、保證足夠的段間距、段首無縮進。

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

<article class="weui_article">

    <h1>大標題</h1>

    <section>

        <h2 class="title">章標題</h2>

        <section>

            <h3>1.1 節標題</h3>

            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod

                tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,

                quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo

                consequat. Duis aute</p>

        </section>

        <section>

            <h3>1.2 節標題</h3>

            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod

                tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,

                cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non

                proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

        </section>

    </section>

</article>

Icon

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

<i class="weui_icon_msg weui_icon_success"></i>

<i class="weui_icon_msg weui_icon_info"></i>

<i class="weui_icon_msg weui_icon_warn"></i>

<i class="weui_icon_msg weui_icon_waiting"></i>

<i class="weui_icon_safe weui_icon_safe_success"></i>

<i class="weui_icon_safe weui_icon_safe_warn"></i>

<div class="icon_sp_area">

    <i class="weui_icon_success"></i>

    <i class="weui_icon_success_circle"></i>

    <i class="weui_icon_success_no_circle"></i>

    <i class="weui_icon_info"></i>

    <i class="weui_icon_waiting"></i>

    <i class="weui_icon_waiting_circle"></i>

    <i class="weui_icon_circle"></i>

    <i class="weui_icon_warn"></i>

    <i class="weui_icon_download"></i>

</div>

相關文章
相關標籤/搜索