小程序原生高顏值組件庫--ColorUI組件庫

簡介

ColorUI是一個Css類的UI組件庫!不是一個Js框架。相比於同類小程序組件庫,ColorUI更注重於視覺交互!html

瀏覽GitHub:https://github.com/weilanwl/ColorUIgit

如何使用?

先下載源碼包

Githubgithub

引入到個人小程序

/demo/ 下的 colorui.wxssicon.wxss 複製到小程序的根目錄下小程序

app.wxss 引入兩個文件bash

@import "icon.wxss";
@import "colorui.wxss";
複製代碼

使用模板全新開發

複製 /template/ 文件夾並重命名爲你的項目,微信開發者工具導入爲小程序就可使用ColorUI了微信

體驗沉浸式導航

App.js
獲取系統參數並寫入全局參數。微信開發

//App.js
App({
  onLaunch: function() {
    wx.getSystemInfo({
      success: e => {
        this.globalData.StatusBar = e.statusBarHeight;
        let custom = wx.getMenuButtonBoundingClientRect();
        this.globalData.Custom = custom;  
        this.globalData.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
      }
    })
  }
})
複製代碼

Page.js 頁面配置獲取全局參數。app

//Page.js
const app = getApp()
Page({
  data: {
    StatusBar: app.globalData.StatusBar,
    CustomBar: app.globalData.CustomBar,
    Custom: app.globalData.Custom
  }  
})
複製代碼

Page.wxml 頁面構造導航。更多導航樣式請下載Demo查閱 操做條組件框架

<view class="cu-custom" style="height:{{CustomBar}}px;">
  <view class="cu-bar fixed bg-gradual-pink" style="height:{{CustomBar}}px;padding-top:{{StatusBar}}px;">
    <navigator class='action border-custom' open-type="navigateBack" delta="1" hover-class="none" style='width:{{Custom.width}}px;height:{{Custom.height}}px;margin-left:calc(750rpx - {{Custom.right}}px)'>
      <text class='icon-back'></text>
      <text class='icon-homefill'></text>
    </navigator>
    <view class='content' style='top:{{StatusBar}}px;'>操做條</view>
  </view>
</view>
複製代碼

自定義系統Tabbar

按照官方 自定義 tabBar 配置好Tabbar (開發工具和版本庫請使用最新版)。xss

使用ColorUI配置Tabbar只須要更改 Wxml 頁的內容便可。 更多Tabbar樣式請下載Demo查閱 操做條組件

/custom-tab-bar/index.wxml

<view class="cu-bar tabbar bg-white shadow">
  <view class="action" wx:for="{{list}}" wx:key="index" data-path="{{item.pagePath}}" data-index="{{index}}" bindtap="switchTab">
    <view class='icon-cu-image'>
      <image src='{{selected === index ? item.selectedIconPath : item.iconPath}}' class='{{selected === index ? "animation" : "animation"}}'></image>
    </view>
    <view class='{{selected === index ? "text-green" : "text-gray"}}'>{{item.text}}</view>
  </view>
</view>
複製代碼

做者叨叨

ColorUI是一個高度自定義的Css樣式庫,包含了開發經常使用的元素和組件,元素組件之間也能相互嵌套使用。我也會不按期更新一些擴展到源碼。

感謝閱讀。

相關文章
相關標籤/搜索