Skip to content

Develop #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/components/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ class App extends Component {
}

onFilter(query) {
reportFilter(query);
if (query) {
reportFilter(query);
}
this.setState({ query });
}

Expand All @@ -62,7 +64,7 @@ class App extends Component {
const { selected, query, elements } = this.state;

let selectedElement = elements[selected];
let visibleElements = Object.values(elements);
let visibleElements = Object.keys(elements).map(key => elements[key]);

if (query) {
visibleElements = visibleElements.filter(element =>
Expand Down
11 changes: 10 additions & 1 deletion src/components/Filter/InputIframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ class InputIframe extends Component {
forceHideKeyboard();
this.setState({
hasInteracted: false,
hasFocused: false,
resetKey: this.state.resetKey + 1
});
}

blur() {
forceHideKeyboard();
if (this.state.hasFocused) {
forceHideKeyboard();
this.setState({ hasFocused: false });
}
}

shouldComponentUpdate(nextProps, nextState) {
Expand All @@ -36,6 +40,11 @@ class InputIframe extends Component {
onLoadFrame() {
const window = this.frameRef.current.contentWindow;
window.addEventListener("input", e => this.onInput(e.target.value));
window.addEventListener("focus", e => this.onFocus(e.target));
}

onFocus() {
this.setState({ hasFocused: true });
}

onInput(value) {
Expand Down
12 changes: 8 additions & 4 deletions src/components/InfoLink/InfoLink.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@

.InfoLink-button {
text-decoration: none;
background: var(--button-fill-color);
border-radius: 2px;
box-shadow: 1px 1px 1px rbga(0, 0, 0, 0.2);
color: var(--button-text-color);
font-weight: bold;
display: inline-block;
margin: 0 8px 8px 0;
padding: 8px 12px;
border-radius: 2px;

background: #ccc;
color: black;

background: var(--button-fill-color);
box-shadow: 1px 1px 1px rbga(0, 0, 0, 0.2);
color: var(--button-text-color);
}

.InfoLink-button:hover,
Expand Down
2 changes: 2 additions & 0 deletions src/components/InfoPanel/InfoPanel.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
justify-content: flex-start;

transition: bottom ease-in-out 200ms;
background: #333;
color: white;
background: var(--panel-background-color);
color: var(--panel-text-color);
box-shadow: 0 -4px rgba(0, 0, 0, 0.2);
Expand Down
24 changes: 11 additions & 13 deletions src/utils/forceHideKeyboard.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
/**
* Fixed positioning will stop scrolling to input.
* Font size over 16px will prevent Safari zooming in on focus.
* https://stackoverflow.com/questions/2989263/disable-auto-zoom-in-input-text-tag-safari-on-iphone
*/
const inputStyle = `
opacity: 0;
position: fixed;
top: -100px;
font-size: 20px;`;

/**
* Create a shim component then focus and unfocus it so that Safari doesn't keep
* the keyboard open for the iframe that was unceremoniously nuked from the DOM.
* Note that this will "flash" the keyboard on some (non-iOS) browsers.
*/
const forceHideKeyboard = () => {
const input = document.createElement("textarea");
input.style = inputStyle;

document.body.prepend(input);
/**
* Fixed positioning will stop scrolling to input.
* Font size over 16px will prevent Safari zooming in on focus.
* https://stackoverflow.com/questions/2989263/disable-auto-zoom-in-input-text-tag-safari-on-iphone
*/
input.style.opacity = 0;
input.style.position = "fixed";
input.style.top = "100px";
input.style.fontSize = "20px";

document.body.appendChild(input);
input.focus();

setTimeout(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/getRandomElement.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const getRandomElement = elements => {
const values = Object.values(elements);
const values = Object.keys(elements).map(key => elements[key]);

// A "count" of all the weights.
const total = values.reduce((total, element) => total + element.weight, 0);
Expand Down