Skip to content
This repository was archived by the owner on Aug 19, 2024. It is now read-only.

Commit e754190

Browse files
author
Irfan Maulana
committed
v.1.0.0
1 parent 50f18e7 commit e754190

14 files changed

+74
-95
lines changed

.babelrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"presets": [
3+
"env"
4+
]
5+
}

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
language: node_js
2+
node_js: '7'
3+
script: npm run test
4+
after_script:
5+
- npm install -g codecov
6+
- codecov

App.vue

Lines changed: 13 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -5,69 +5,23 @@
55

66
<div class="app">
77
<div class="grid__row content centered">
8-
<h1>Lightweight and Customizable Vue Currency Filter Plugins By Irfan Maulana</h1>
8+
<h1>Lightweight Vue 2 String Manipulation Filter By Irfan Maulana</h1>
99

10-
<h2>Example : </h2>
11-
<input type="tel" pattern="[0-9]*" v-model="textInput" class="textfield textfield--shadow"/>
12-
13-
<div><b>Before filter</b> : {{ textInput }}</div>
14-
<div>
15-
<b>After filter</b> :
16-
<b class="result__filter">{{ textInput | currency(configSymbol, configSeparator, configFractionCount, configFractionSeparator, configSymbolPosition, configSymbolSpacing) }}</b>
17-
</div>
18-
19-
<h2>Customize Config :</h2>
20-
<div class="form__group">
21-
<div class="form__icon form__icon--radius-left">
22-
Symbol
23-
</div>
24-
<input class="textfield" type="text" v-model="configSymbol">
25-
</div>
26-
27-
<div class="form__group">
28-
<div class="form__icon form__icon--radius-left">
29-
Separator
30-
</div>
31-
<input class="textfield" type="text" v-model="configSeparator">
32-
</div>
33-
34-
<div class="form__group">
35-
<div class="form__icon form__icon--radius-left">
36-
Fraction Count
37-
</div>
38-
<input class="textfield" type="tel" pattern="[0-9]*" v-model="configFractionCount">
39-
</div>
4010

41-
<div class="form__group">
42-
<div class="form__icon form__icon--radius-left">
43-
Fraction Separator
44-
</div>
45-
<input class="textfield" type="text" v-model="configFractionSeparator">
11+
<div>
12+
<b>Before filter</b> : {{ textInput }}
4613
</div>
47-
48-
<div class="form__group m-b-5">
49-
<div class="form__icon form__icon--radius-left">
50-
Symbol Position
51-
</div>
52-
<div class="form__wrapper">
53-
<input class="radio radio--blue" type="radio" id="radio-form-1" name="radio-symbol" v-model="configSymbolPosition" v-bind:value="'front'">
54-
<label for="radio-form-1">Front</label>
55-
<input class="radio radio--blue" type="radio" id="radio-form-2" name="radio-symbol" v-model="configSymbolPosition" v-bind:value="'back'">
56-
<label for="radio-form-2">End of text</label>
57-
</div>
14+
<div>
15+
<b>Uppercase</b> : <b class="result__uppercase">{{ textInput | uppercase }}</b>
16+
<br>
17+
<b>Lowercase</b> : <b class="result__lowercase">{{ textInput | lowercase }}</b>
18+
<br>
19+
<b>Capitalize</b> : <b class="result__capitalize">{{ textInput | capitalize }}</b>
20+
<br>
21+
<b>Titlecase</b> : <b class="result__titlecase">{{ textInput | titlecase }}</b>
22+
<br>
5823
</div>
5924

60-
<div class="form__group m-b-5">
61-
<div class="form__icon form__icon--radius-left">
62-
Symbol Spacing
63-
</div>
64-
<div class="form__wrapper">
65-
<input class="radio radio--blue" type="radio" id="radio-form-3" name="radio-spacing" v-model="configSymbolSpacing" v-bind:value="true">
66-
<label for="radio-form-3">Yes</label>
67-
<input class="radio radio--blue" type="radio" id="radio-form-4" name="radio-spacing" v-model="configSymbolSpacing" v-bind:value="false">
68-
<label for="radio-form-4">No</label>
69-
</div>
70-
</div>
7125

7226
</div>
7327
</div>
@@ -84,29 +38,13 @@ export default {
8438
name: 'app',
8539
data () {
8640
return {
87-
textInput: 20000,
88-
configSymbol: '$',
89-
configSeparator: '.',
90-
configFractionCount: 0,
91-
configFractionSeparator: ',',
92-
configSymbolPosition: 'front',
93-
configSymbolSpacing: true
41+
textInput: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'
9442
}
9543
}
9644
}
97-
9845
</script>
9946

10047
<style lang="scss">
101-
.form__group{
102-
max-width: 500px;
103-
}
104-
.form__icon{
105-
width: 180px;
106-
}
107-
.form__wrapper{
108-
margin-left: 5px;
109-
}
11048
.m-b-5{
11149
margin-bottom: 5px;
11250
}

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
+ `uppercase`
2323
+ `lowercase`
2424
+ `capitalize`
25+
+ `titlecase`
2526

2627
## Download
2728

@@ -48,7 +49,10 @@ Vue.use(VueStringFilter)
4849
#### Use in View :
4950

5051
```html
51-
<span>{{ 20000 | currency}}</span>
52+
<span>{{ stringWillFormatted | uppercase }}</span>
53+
<span>{{ stringWillFormatted | lowercase }}</span>
54+
<span>{{ stringWillFormatted | capitalize }}</span>
55+
<span>{{ stringWillFormatted | titlecase }}</span>
5256
```
5357

5458

VueStringFilter.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
const VueStringFilter = {
2-
install (Vue, options) {
3-
4-
// helper to check undefined variable
5-
function _isUndefined (obj) {
6-
return typeof obj === "undefined"
7-
}
8-
9-
if(_isUndefined(options)) options = {}
2+
install(Vue, options) {
103

114
Vue.filter('lowercase', function (value) {
12-
return value
5+
6+
return value.toString().toLowerCase()
137
})
148

159
Vue.filter('uppercase', function (value) {
16-
return value
10+
11+
return value.toString().toUpperCase()
1712
})
1813

1914
Vue.filter('capitalize', function (value) {
20-
return value
15+
16+
return value.charAt(0).toUpperCase() + value.slice(1)
17+
})
18+
19+
Vue.filter('titlecase', function (value) {
20+
21+
return value.replace(/\w\S*/g, function (txt) {
22+
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase()
23+
})
2124
})
2225

2326
}

dist/VueStringFilter.bundle.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/VueStringFilter.bundle.js.gz

574 Bytes
Binary file not shown.

dist/VueStringFilter.bundle.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/bundle.js

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/bundle.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)