Skip to content

Commit 06b9920

Browse files
committed
st-container component with conditional st-if attribute.
1 parent daea08f commit 06b9920

11 files changed

+8083
-2
lines changed

.editorconfig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# http://editorconfig.org
2+
3+
root = true
4+
5+
[*]
6+
charset = utf-8
7+
indent_style = space
8+
indent_size = 2
9+
end_of_line = lf
10+
insert_final_newline = true
11+
trim_trailing_whitespace = true
12+
13+
[*.md]
14+
insert_final_newline = false
15+
trim_trailing_whitespace = false

.gitignore

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
dist/
2+
www/
3+
4+
*~
5+
*.sw[mnpcod]
6+
*.log
7+
*.lock
8+
*.tmp
9+
*.tmp.*
10+
log.txt
11+
*.sublime-project
12+
*.sublime-workspace
13+
14+
.idea/
15+
.vscode/
16+
.sass-cache/
17+
.versions/
18+
node_modules/
19+
$RECYCLE.BIN/
20+
21+
.DS_Store
22+
Thumbs.db
23+
UserInterfaceState.xcuserstate
24+
.env

README.md

+104-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,104 @@
1-
# stencil-container
2-
A stencil component that dispalys child element with conditional data.
1+
# Stencil Container
2+
A stencil component that displays child elements with conditional data.
3+
4+
## Using this component
5+
6+
### Script tag
7+
8+
- Put `<script src='https://unpkg.com/stencil-container@latest/dist/stencil-container.js'></script>` in the head of your index.html
9+
- Then you can use the element `<st-container>` anywhere in your template, JSX, html etc
10+
11+
### Node Modules
12+
- Run `npm install stencil-container --save`
13+
- Put a script tag similar to this `<script src='node_modules/stencil-container/dist/stencil-container.js'></script>` in the head of your index.html
14+
- Then you can use the element `<st-container>` anywhere in your template, JSX, html etc
15+
16+
### In a stencil-starter app
17+
- Run `npm install stencil-container --save`
18+
- You might need to import the npm package in a tsx file with `import { } from 'stencil-container';`
19+
- Then you can use the element `<st-container>` anywhere in your template, JSX, html etc
20+
21+
## Parameters
22+
23+
### ng-if
24+
25+
An expression that is either true or false.
26+
27+
## Examples
28+
29+
### Plain html
30+
31+
`<st-container st-if="false"><div>false?</div></st-container>`
32+
Will not show the child elements content.
33+
34+
`<st-container st-if="true"><div>true?</div></st-container>`
35+
Will show the child elements content.
36+
37+
`<st-container><div>container test?</div></st-container>`
38+
Without the st-if parameter it assumes the content should be shown.
39+
40+
### Javascript variables
41+
42+
```html
43+
<script>
44+
var numberOne = 1;
45+
var numberTwo = 2;
46+
var booleanTrue = true;
47+
var booleanFalse = false;
48+
</script>
49+
50+
<st-container st-if="booleanTrue"><div>Will be shown!</div></st-container>
51+
<st-container st-if="booleanFalse"><div>Will not be shown!</div></st-container>
52+
<st-container st-if="numberOne"><div>Will be shown!</div></st-container>
53+
<st-container st-if="numberTwo"><div>Will be shown!</div></st-container>
54+
<st-container st-if="numberOne == numberOne"><div>Will be shown!</div></st-container>
55+
<st-container st-if="numberOne == numberTwo"><div>Will not be shown!</div></st-container>
56+
```
57+
58+
### JSX variables
59+
60+
```jsx
61+
export class MyApp {
62+
private expression1 = '1 == 1';
63+
private expression2 = '1 == 2';
64+
65+
render() {
66+
return (
67+
<div>
68+
<st-container st-if={this.expression1}><div>Will be shown!</div></st-container>
69+
<st-container st-if={this.expression2}><div>Will not be shown!</div></st-container>
70+
</div>
71+
);
72+
}
73+
}
74+
```
75+
76+
### Angular bindings
77+
78+
Let me know if it works! :)
79+
80+
## Development
81+
82+
Installation:
83+
```bash
84+
git clone https://github.com/nerdic-coder/stencil-container.git stencil-container
85+
cd stencil-container
86+
npm install
87+
```
88+
89+
Running:
90+
```bash
91+
npm start
92+
```
93+
94+
Tests:
95+
```bash
96+
npm run test
97+
```
98+
99+
Watchable tests:
100+
```bash
101+
npm run test.watch
102+
```
103+
104+
All feedback are welcome!

0 commit comments

Comments
 (0)