-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add qr code to invite dialog (#23)
* feat: add qr code to invite dialog * save qr code visibility
- Loading branch information
Showing
11 changed files
with
419 additions
and
55 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 24 additions & 2 deletions
26
frontend/src/app/components/invite-players-dialog/invite-players-dialog.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,32 @@ | ||
<div class="invite-players-dialog fx-layout-column fx-gap--2em"> | ||
<h2 mat-dialog-title>{{ 'components.invitePlayersDialog.title' | translate }}</h2> | ||
<div mat-dialog-content> | ||
<div class="fx-layout-column fx-align--x-center fx-align--center-x qr"> | ||
<qrcode [qrdata]="gameUrl" | ||
*ngIf="(qrCodeVisible$ | async)" | ||
elementType="svg" | ||
[colorLight]="'00000000'" | ||
cssClass="full-house-qr" | ||
[margin]="0" | ||
[width]="240"> | ||
</qrcode> | ||
</div> | ||
<mat-form-field appearance="fill"> | ||
<mat-label>{{ 'components.invitePlayersDialog.urlLabel' | translate }}</mat-label> | ||
<input matInput #input autofocus readonly name="gameurl" [value]="gameUrl" /> | ||
<input matInput #input autofocus readonly name="gameurl" [value]="gameUrl"/> | ||
</mat-form-field> | ||
<button mat-flat-button color="primary" (click)="copyUrl()">{{ 'components.invitePlayersDialog.copyButton' | translate }}</button> | ||
<button mat-flat-button color="primary" (click)="copyUrl()"> | ||
<div class="fx-layout-row fx-align--center-x fx-align--x-center fx-gap--8px"> | ||
<mat-icon svgIcon="content-copy"></mat-icon> | ||
<span>{{ 'components.invitePlayersDialog.copyButton' | translate }}</span> | ||
</div> | ||
</button> | ||
|
||
<button class="show-qr-button" tabindex="-1" mat-stroked-button color="primary" (click)="toggleQrCodeVisibility()"> | ||
<div class="fx-layout-row fx-align--center-x fx-align--x-center fx-gap--8px"> | ||
<mat-icon svgIcon="qr-code-scanner"></mat-icon> | ||
<span>{{ 'components.invitePlayersDialog.showQrButton' | translate: {visible: (qrCodeVisible$ | async)} }}</span> | ||
</div> | ||
</button> | ||
</div> | ||
</div> |
10 changes: 9 additions & 1 deletion
10
frontend/src/app/components/invite-players-dialog/invite-players-dialog.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,20 @@ | ||
.invite-players-dialog { | ||
padding: 2em; | ||
|
||
h1 { | ||
h2 { | ||
margin: 0; | ||
} | ||
|
||
mat-form-field, button { | ||
width: 100%; | ||
} | ||
|
||
.show-qr-button { | ||
margin-top: 1em; | ||
} | ||
|
||
.qr { | ||
margin-bottom: 1em; | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
frontend/src/app/components/invite-players-dialog/invite-players-dialog.component.theme.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
@use '@angular/material' as mat; | ||
@import "src/styles/mixins"; | ||
|
||
@mixin invite-players-dialog-theme($theme) { | ||
$primary: map-get($theme, primary); | ||
.full-house-qr { | ||
svg { | ||
path { | ||
stroke: mat.get-color-from-palette($primary, 500); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import {UserState} from "./user/user.state"; | ||
import {ThemingState} from "./theming/theming.state"; | ||
import {SettingsState} from "./settings/settings.state"; | ||
|
||
export const appStates = [ | ||
ThemingState, | ||
UserState | ||
UserState, | ||
SettingsState | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import {Action, NgxsOnInit, Selector, State, StateContext, Store} from '@ngxs/store'; | ||
import {Injectable} from '@angular/core'; | ||
import {filter, first} from 'rxjs/operators'; | ||
|
||
export interface SettingsStateModel { | ||
inviteQrCodeVisible: boolean; | ||
} | ||
|
||
const defaultState: SettingsStateModel = { | ||
inviteQrCodeVisible: false | ||
}; | ||
|
||
export class ToggleQrCodeVisibility { | ||
static readonly type = '[Settings] Toggle QR code visibility'; | ||
|
||
} | ||
|
||
@State({ | ||
name: 'ppSettings', | ||
defaults: defaultState | ||
}) | ||
@Injectable() | ||
export class SettingsState { | ||
|
||
@Selector() | ||
static isInviteQrCodeVisible(state: SettingsStateModel): boolean { | ||
return state.inviteQrCodeVisible; | ||
} | ||
|
||
@Action(ToggleQrCodeVisibility) | ||
toggleQrCodeVisibility(ctx: StateContext<SettingsStateModel>) { | ||
ctx.patchState({ | ||
inviteQrCodeVisible: !ctx.getState().inviteQrCodeVisible | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters