Skip to content

Commit a152629

Browse files
Merge pull request #486 from suresh-gangumalla/v2/create-app
Added .blits file extension based app creation
2 parents 0da9f9b + 92d1b1c commit a152629

File tree

40 files changed

+534
-21
lines changed

40 files changed

+534
-21
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<template>
2+
<Element>
3+
<RouterView />
4+
</Element>
5+
</template>
6+
7+
<script>
8+
9+
import Blits from '@lightningjs/blits'
10+
import Home from './pages/Home.blits'
11+
12+
export default Blits.Component('App', {
13+
routes: [{ path: '/', component: Home }],
14+
})
15+
</script>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<template>
2+
<Element>
3+
<Circle size="40" :color="$loaderColor || '#94a3b8'" :alpha.transition="{value: $alpha, delay: 200}" />
4+
<Circle size="40" :color="$loaderColor || '#94a3b8'" x="60" :alpha.transition="{value: $alpha, delay: 300}" />
5+
<Circle size="40" :color="$loaderColor || '#94a3b8'" x="120" :alpha.transition="{value: $alpha, delay: 400}" />
6+
</Element>
7+
</template>
8+
9+
<script>
10+
11+
import Blits from '@lightningjs/blits'
12+
13+
export default Blits.Component('Loader', {
14+
/**
15+
* @type {{'loaderColor'}}
16+
*/
17+
props: {
18+
loaderColor: undefined
19+
},
20+
state() {
21+
return {
22+
/**
23+
* Alpha of the circles, used to create a fade-in / fade-out transition
24+
*/
25+
alpha: 0,
26+
}
27+
},
28+
hooks: {
29+
ready() {
30+
this.start()
31+
},
32+
},
33+
methods: {
34+
/**
35+
* Starts the loading transition in an interval
36+
* @returns {void}
37+
*/
38+
start() {
39+
this.$setInterval(() => {
40+
this.alpha = this.alpha === 1 ? 0 : 1
41+
}, 800)
42+
},
43+
},
44+
})
45+
</script>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import Blits from '@lightningjs/blits'
2+
import App from './App.blits'
3+
4+
Blits.Launch(App, 'app', {
5+
w: 1920,
6+
h: 1080,
7+
debugLevel: 1,
8+
defaultFont: 'lato',
9+
fonts: [
10+
{
11+
family: 'lato',
12+
type: 'msdf',
13+
file: 'fonts/Lato-Regular.ttf',
14+
},
15+
{
16+
family: 'raleway',
17+
type: 'msdf',
18+
file: 'fonts/Raleway-ExtraBold.ttf',
19+
},
20+
{
21+
family: 'opensans',
22+
type: 'web',
23+
file: 'fonts/OpenSans-Medium.ttf',
24+
},
25+
],
26+
})
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<template>
2+
<Element w="1920" h="1080" color="#1e293b">
3+
<Element :y.transition="$y">
4+
<Element
5+
src="assets/logo.png"
6+
w="200"
7+
h="200"
8+
:scale.transition="{value: $scale, duration: 500}"
9+
:rotation.transition="{value: $rotation, duration: 800}"
10+
:x.transition="{value: $x, delay: 200, duration: 1200, easing: 'cubic-bezier(1,-0.64,.39,1.44)'}"
11+
mount="{x: 0.5}"
12+
y="320"
13+
rounded="8"
14+
/>
15+
<Loader :x="1920 / 2" mount="{x: 0.5}" y="600" w="160" :alpha.transition="$loaderAlpha" :loaderColor="$color" />
16+
<Element y="600" :alpha.transition="$textAlpha">
17+
<Text size="80" align="center" maxwidth="1920">Hello!</Text>
18+
<Text
19+
size="50"
20+
align="center"
21+
y="120"
22+
:x="1920/2"
23+
maxwidth="500"
24+
lineheight="64"
25+
mount="{x: 0.5}"
26+
color="#ffffffaa"
27+
content="Let's get started with Lightning 3 & Blits"
28+
/>
29+
</Element>
30+
</Element>
31+
</Element>
32+
</template>
33+
34+
<script>
35+
36+
import Blits from '@lightningjs/blits'
37+
import Loader from '../components/Loader.blits'
38+
39+
const colors = ['#f5f3ff', '#ede9fe', '#ddd6fe', '#c4b5fd', '#a78bfa']
40+
41+
export default Blits.Component('Home', {
42+
components: {
43+
Loader,
44+
},
45+
state() {
46+
return {
47+
/**
48+
* Y-position of the entire page contents
49+
* @type {number}
50+
*/
51+
y: 0,
52+
/**
53+
* X-position of the logo, used to create slide in transition
54+
* @type {number}
55+
*/
56+
x: -1000,
57+
/**
58+
* Rotation of the logo, used to create a spinning transition
59+
* @type {number}
60+
*/
61+
rotation: 0,
62+
/**
63+
* Scale of the logo, used to create a zoom-in / zoom-out transition
64+
* @type {number}
65+
*/
66+
scale: 1,
67+
/**
68+
* Alpha of the loader component, used to create a fade-in / fade-out transition
69+
* @type {number}
70+
*/
71+
loaderAlpha: 0,
72+
/**
73+
* Alpha of the text, used to create a fade-in transition
74+
* @type {number}
75+
*/
76+
textAlpha: 0,
77+
/**
78+
* Color passed into the loader component
79+
* @type {string}
80+
*/
81+
color: '',
82+
}
83+
},
84+
hooks: {
85+
ready() {
86+
this.rotateColors(200)
87+
88+
this.loaderAlpha = 1
89+
this.x = 1920 / 2
90+
91+
this.$setTimeout(() => {
92+
this.rotation = 720
93+
this.scale = 1.5
94+
}, 3000)
95+
96+
this.$setTimeout(() => {
97+
this.scale = 1
98+
}, 3000 + 300)
99+
100+
this.$setTimeout(() => {
101+
this.y = -60
102+
this.loaderAlpha = 0
103+
this.scale = 1
104+
this.textAlpha = 1
105+
}, 6000)
106+
},
107+
},
108+
methods: {
109+
/**
110+
* Method to rotate the colors of the loader
111+
* @param {number} interval - interval in ms
112+
*/
113+
rotateColors(interval) {
114+
let i = 0
115+
this.$setInterval(() => {
116+
i++
117+
if (i >= colors.length) i = 0
118+
this.color = colors[i]
119+
}, interval)
120+
},
121+
},
122+
})
123+
</script>

0 commit comments

Comments
 (0)