Skip to content

Commit d625ddf

Browse files
Right side auth webview (#3352)
authWebview: Right side container + reactive in portrait Signed-off-by: Nikolas Komonen <[email protected]>
1 parent 1995722 commit d625ddf

File tree

3 files changed

+118
-34
lines changed

3 files changed

+118
-34
lines changed

src/credentials/vue/ServiceItem.vue

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
of the service items.
88
-->
99
<template>
10-
<button class="service-item-container" :class="classWhenIsSelected" v-on:mousedown="serviceItemClicked">
10+
<li class="service-item-container" :class="classWhenIsSelected" v-on:mousedown="serviceItemClicked">
1111
<!-- The icon -->
1212
<div class="icon-item" :class="serviceIconClass"></div>
1313

@@ -20,10 +20,16 @@
2020
{{ description }}
2121
</div>
2222
</div>
23-
</button>
23+
</li>
24+
25+
<li class="service-item-content-list-item">
26+
<!-- See 'Named Slots' for more info -->
27+
<slot name="service-item-content-slot"></slot>
28+
</li>
2429
</template>
2530
<script lang="ts">
2631
import { defineComponent, PropType } from 'vue'
32+
import { ServiceItemContent } from './ServiceItemContent.vue'
2733
2834
/* The status of the icon for a service */
2935
type ServiceIconStatus = keyof typeof serviceIconClasses
@@ -58,6 +64,8 @@ export interface StaticServiceItemProps {
5864
*/
5965
export default defineComponent({
6066
name: 'ServiceItem',
67+
components: { ServiceItemContent },
68+
emits: ['service-item-clicked'],
6169
props: {
6270
id: {
6371
type: String as PropType<ServiceItemId>,
@@ -79,6 +87,11 @@ export default defineComponent({
7987
type: Boolean,
8088
default: false,
8189
},
90+
isLandscape: {
91+
type: Boolean,
92+
required: true,
93+
description: 'Whether the screen is in landscape mode or not.',
94+
},
8295
},
8396
data() {
8497
return {
@@ -151,7 +164,7 @@ export class ServiceItemsState {
151164
private readonly unlockedServices: Set<ServiceItemId> = new Set(['NON_AUTH_FEATURES'])
152165
153166
/** Note a service item is pre-selected by default */
154-
private currentlySelected: ServiceItemId = 'NON_AUTH_FEATURES'
167+
private currentlySelected?: ServiceItemId = 'NON_AUTH_FEATURES'
155168
156169
/**
157170
* The Ids of the service items, separated by the ones that are locked vs. unlocked
@@ -180,7 +193,7 @@ export class ServiceItemsState {
180193
}
181194
182195
/** The currently selected service item */
183-
get selected(): ServiceItemId {
196+
get selected(): ServiceItemId | undefined {
184197
return this.currentlySelected
185198
}
186199
@@ -189,6 +202,18 @@ export class ServiceItemsState {
189202
this.currentlySelected = id
190203
}
191204
205+
deselect() {
206+
this.currentlySelected = undefined
207+
}
208+
209+
toggleSelected(id: ServiceItemId) {
210+
if (this.currentlySelected === id) {
211+
this.deselect()
212+
} else {
213+
this.select(id)
214+
}
215+
}
216+
192217
/** Marks the item as being 'unlocked', implying the required auth is completed. */
193218
unlock(id: ServiceItemId) {
194219
this.unlockedServices.add(id)
@@ -209,19 +234,18 @@ export class ServiceItemsState {
209234
display: flex;
210235
margin-top: 10px;
211236
padding: 20px 15px 20px 15px;
212-
width: 100%;
237+
238+
min-height: 35px;
213239
214240
border-style: solid;
215241
border-width: 2px;
216242
border-radius: 4px;
217243
border-color: transparent;
218244
219-
/* Assumes that description is a single line.
220-
If it can be multiple lines this value should be re-evaluated */
221-
height: 75px;
222-
223245
/* Icon and text are centered on the secondary axis */
224246
align-items: center;
247+
248+
cursor: pointer;
225249
}
226250
227251
/* When a service item was clicked */
@@ -273,4 +297,10 @@ export class ServiceItemsState {
273297
flex-direction: column;
274298
text-align: left;
275299
}
300+
301+
/* ******** Service Item Content Container ******** */
302+
303+
.service-item-content-list-item:empty {
304+
display: none;
305+
}
276306
</style>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<template>
2+
<div id="service-item-content-container">TODO</div>
3+
</template>
4+
<script lang="ts">
5+
import { defineComponent } from 'vue'
6+
7+
export const ServiceItemContent = defineComponent({})
8+
9+
export default ServiceItemContent
10+
</script>
11+
<style>
12+
#service-item-content-container {
13+
display: flex;
14+
flex-direction: column;
15+
align-items: center;
16+
justify-content: center;
17+
18+
border-style: solid;
19+
border-width: 2px;
20+
border-radius: 4px;
21+
border-color: #0097fb;
22+
23+
width: 700px;
24+
height: 100%;
25+
26+
/* For testing purposes, before we have content to fill */
27+
min-height: 600px;
28+
}
29+
</style>

src/credentials/vue/root.vue

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,89 @@
11
<template>
2-
<div class="flex-container" style="display: flex">
2+
<div class="flex-container">
33
<div id="left-column">
44
<div>
55
<h1>Select a feature to get started</h1>
6-
<div v-for="itemId in unlockedItemIds">
6+
<ul class="service-item-list" v-for="itemId in unlockedItemIds">
77
<ServiceItem
88
:title="getServiceItemProps(itemId).title"
99
:description="getServiceItemProps(itemId).description"
1010
:status="'UNLOCKED'"
1111
:isSelected="isServiceSelected(itemId)"
12+
:isLandscape="isLandscape"
1213
:id="itemId"
1314
:key="buildServiceItemKey(itemId, 'UNLOCKED')"
1415
@service-item-clicked="serviceWasSelected(itemId)"
1516
>
17+
<template v-slot:service-item-content-slot v-if="isServiceSelected(itemId) && !isLandscape">
18+
<ServiceItemContent></ServiceItemContent>
19+
</template>
1620
</ServiceItem>
17-
</div>
21+
</ul>
1822
</div>
1923

2024
<div>
2125
<h3>UNLOCK ADDITIONAL FEATURES</h3>
2226
<div>Some features have additional authentication requirements to use. <a>Read more.</a></div>
2327

24-
<div v-for="itemId in lockedItemIds">
28+
<ul class="service-item-list" v-for="itemId in lockedItemIds">
2529
<ServiceItem
2630
:title="getServiceItemProps(itemId).title"
2731
:description="getServiceItemProps(itemId).description"
2832
:status="'LOCKED'"
2933
:isSelected="isServiceSelected(itemId)"
34+
:isLandscape="isLandscape"
3035
:id="itemId"
3136
:key="buildServiceItemKey(itemId, 'LOCKED')"
3237
@service-item-clicked="serviceWasSelected(itemId)"
3338
>
39+
<template v-slot:service-item-content-slot v-if="isServiceSelected(itemId) && !isLandscape">
40+
<ServiceItemContent></ServiceItemContent>
41+
</template>
3442
</ServiceItem>
35-
</div>
43+
</ul>
3644
</div>
3745
<h3></h3>
3846
</div>
39-
<div id="right-column"></div>
47+
<div v-if="isLandscape && isAnyServiceSelected" id="right-column">
48+
<ServiceItemContent></ServiceItemContent>
49+
</div>
4050
</div>
4151
</template>
4252

4353
<script lang="ts">
4454
import { defineComponent } from 'vue'
4555
import ServiceItem, { ServiceItemsState, ServiceItemId, ServiceStatus, StaticServiceItemProps } from './ServiceItem.vue'
56+
import ServiceItemContent from './ServiceItemContent.vue'
4657
4758
const serviceItemsState = new ServiceItemsState()
4859
4960
export default defineComponent({
50-
components: { ServiceItem },
61+
components: { ServiceItem, ServiceItemContent },
5162
name: 'AuthRoot',
5263
data() {
5364
return {
5465
unlockedItemIds: [] as ServiceItemId[],
5566
lockedItemIds: [] as ServiceItemId[],
67+
currWindowWidth: window.innerWidth,
5668
}
5769
},
5870
created() {
5971
this.renderItems()
6072
},
73+
mounted() {
74+
window.addEventListener('resize', this.updateWindowWidth)
75+
},
76+
unmounted() {
77+
window.removeEventListener('resize', this.updateWindowWidth)
78+
},
79+
computed: {
80+
isLandscape() {
81+
return this.currWindowWidth > 1300
82+
},
83+
isAnyServiceSelected(): boolean {
84+
return serviceItemsState.selected !== undefined
85+
},
86+
},
6187
methods: {
6288
/**
6389
* Triggers a rendering of the service items.
@@ -86,6 +112,9 @@ export default defineComponent({
86112
buildServiceItemKey(id: ServiceItemId, lockStatus: ServiceStatus) {
87113
return id + '_' + (this.isServiceSelected(id) ? `${lockStatus}_SELECTED` : `${lockStatus}`)
88114
},
115+
updateWindowWidth() {
116+
this.currWindowWidth = window.innerWidth
117+
},
89118
},
90119
})
91120
</script>
@@ -95,32 +124,28 @@ export default defineComponent({
95124
.flex-container {
96125
display: flex;
97126
flex-direction: row;
98-
width: 1200px;
99-
}
100-
101-
/* Makes webview responsive and changes to single column when necessary */
102-
@media (max-width: 1200px) {
103-
.flex-container {
104-
flex-direction: column;
105-
106-
color: red;
107-
}
108127
}
109128
110129
#left-column {
111-
flex-grow: 1;
112-
max-width: 40%;
130+
width: 500px;
113131
box-sizing: border-box;
114132
margin: 10px;
115133
}
116134
117-
#right-column {
118-
flex-grow: 1;
119-
max-width: 60%;
135+
.service-item-list {
136+
list-style-type: none;
137+
margin: 0;
138+
padding: 0;
139+
}
120140
141+
.service-item-list li {
142+
/* Creates an even separation between all list items*/
143+
margin-top: 10px;
144+
}
145+
146+
#right-column {
121147
/* This can be deleted, for development purposes */
122-
background-color: aqua;
123-
color: black;
124-
height: 200px;
148+
height: 800px;
149+
margin: 10px;
125150
}
126151
</style>

0 commit comments

Comments
 (0)