Skip to content

Commit

Permalink
feat: 新增 .m-pure-button 样式
Browse files Browse the repository at this point in the history
  • Loading branch information
fjc0k committed Mar 26, 2019
1 parent 78e72e4 commit 95ea771
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 6 deletions.
19 changes: 17 additions & 2 deletions project.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,15 @@
"list": []
},
"miniprogram": {
"current": 5,
"current": 7,
"list": [
{
"id": -1,
"name": "pages/Home",
"pathName": "pages/Home",
"query": "",
"scene": null
},
{
"id": -1,
"name": "pages/Sticky",
Expand Down Expand Up @@ -71,9 +78,17 @@
"id": -1,
"name": "pages/SinglePicker",
"pathName": "pages/SinglePicker",
"query": "",
"scene": null
},
{
"id": 6,
"name": "pages/Style",
"pathName": "pages/Style",
"query": "",
"scene": null
}
]
}
}
}
}
3 changes: 2 additions & 1 deletion src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import { component } from './components/component'
class App extends component() {
config: Taro.Config = {
pages: [
// @index('./pages/*.tsx', (pp, cc) => `'${pp.path.replace(/^\.\//, '')}',`)
'pages/Home',
// @index('./pages/*[!Home].tsx', (pp, cc) => `'${pp.path.replace(/^\.\//, '')}',`)
'pages/Picker',
'pages/PickerView',
'pages/Popup',
'pages/SinglePicker',
'pages/Sticky',
'pages/Style',
'pages/Transition',
// @endindex
],
Expand Down
34 changes: 34 additions & 0 deletions src/components/Style/PureButton.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@import '../../styles/settings.scss';

/**
* 去除原生 Button 组件自带的样式。
* 现在它与 View 组件的唯一区别:
* 内容默认居中。
*/
button.m-pure-button {
position: relative;
display: block;
text-align: center;
margin: 0;
padding: 0;
outline: none;
font: inherit;
border-radius: 0;
border: none;
color: inherit;
background: inherit;
overflow: auto;
box-sizing: content-box;
text-decoration: none;
-webkit-tap-highlight-color: transparent;

&.button-hover {
color: inherit;
background: inherit;
}

&::before,
&::after {
content: none;
}
}
4 changes: 2 additions & 2 deletions src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @index('./[A-Z]*', (pp, cc) => `export { default as M${pp.name} } from '${pp.path}'`)
// @index(['./[A-Z]*', '!./Style'], (pp, cc) => `export { default as M${pp.name} } from '${pp.path}'`)
export { default as MPicker } from './Picker'
export { default as MPickerView } from './PickerView'
export { default as MPopup } from './Popup'
Expand All @@ -8,7 +8,7 @@ export { default as MTransition } from './Transition'
// @endindex

export type ComponentName = (
// @index('./[A-Z]*', (pp, cc, { last }) => `'${pp.name}'${last ? '' : ' |'}`)
// @index(['./[A-Z]*', '!./Style'], (pp, cc, { last }) => `'${pp.name}'${last ? '' : ' |'}`)
'Picker' |
'PickerView' |
'Popup' |
Expand Down
5 changes: 5 additions & 0 deletions src/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ const componentList: ComponentInfo[] = [
chineseName: '单项选择器',
url: pageUrls.SinglePicker,
},
{
name: 'Style' as any,
chineseName: '样式',
url: pageUrls.Style,
},
]

export default class Home extends component({
Expand Down
26 changes: 26 additions & 0 deletions src/pages/Style.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Taro from '@tarojs/taro'
import { Button, View } from '@tarojs/components'
import { component } from '../components/component'
import { XItem, XList, XTitle } from './components'

export default class Style extends component() {
render() {
return (
<View>
<XTitle>.m-pure-button</XTitle>
<XList>
<XItem
title='去除原生 Button 组件自带的样式,仅保留文字居中,如:'
/>
<XItem>
<Button
className='m-pure-button'
openType='openSetting'>
{'打开设置'}
</Button>
</XItem>
</XList>
</View>
)
}
}
2 changes: 1 addition & 1 deletion src/pages/components/Item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

.item {
position: relative;
padding: 0 15px;
padding: 10px 15px;
min-height: 50px;
box-sizing: border-box;
display: flex;
Expand Down
1 change: 1 addition & 0 deletions src/pages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const pageUrls = {
Popup: '/pages/Popup' as '/pages/Popup',
SinglePicker: '/pages/SinglePicker' as '/pages/SinglePicker',
Sticky: '/pages/Sticky' as '/pages/Sticky',
Style: '/pages/Style' as '/pages/Style',
Transition: '/pages/Transition' as '/pages/Transition',
// @endindex
}
1 change: 1 addition & 0 deletions src/styles/components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
@import '../components/PickerView/index.scss';
@import '../components/Popup/index.scss';
@import '../components/Sticky/index.scss';
@import '../components/Style/PureButton.scss';
@import '../components/Transition/index.scss';

0 comments on commit 95ea771

Please sign in to comment.