-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Adding infobar to screencast (#2432)
This PR adds an infobar component which is used to display a warning to screencast users about the limitation of the view.
- Loading branch information
Showing
7 changed files
with
98 additions
and
1 deletion.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
import { html, render } from 'lit-html'; | ||
import { createRef, ref } from 'lit-html/directives/ref.js' | ||
import { styleMap, StyleInfo } from 'lit-html/directives/style-map.js'; | ||
|
||
interface InfobarProps { | ||
message: string; | ||
} | ||
|
||
export default class InfobarComponent { | ||
#buttonRef = createRef(); | ||
#message: string; | ||
#container: HTMLElement | undefined; | ||
|
||
constructor(props: InfobarProps, container?: HTMLElement) { | ||
this.#message = props.message; | ||
this.#container = container; | ||
this.#update(); | ||
} | ||
|
||
#update(styles?: StyleInfo) { | ||
let customStyles = styles ?? { | ||
display: 'flex' | ||
}; | ||
|
||
if (!this.#container) { | ||
return; | ||
} | ||
render(this.template(customStyles), this.#container); | ||
} | ||
|
||
template(styles: StyleInfo) { | ||
return html` | ||
<div class="infobar" style=${styleMap(styles)}> | ||
<div class="infobar-message">${this.#message}</div> | ||
<button class="infobar-close-button" ${ref(this.#buttonRef)} @click=${this.#onClick}></button> | ||
</div> | ||
`; | ||
} | ||
|
||
#onClick = () => { | ||
let styles = { | ||
display: 'none', | ||
} as StyleInfo; | ||
|
||
this.#update(styles); | ||
}; | ||
|
||
static render(props: InfobarProps, elementId: string) { | ||
const currentContainer = document.getElementById(elementId); | ||
if (currentContainer) { | ||
new InfobarComponent(props, currentContainer); | ||
} | ||
} | ||
} |
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
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