Skip to content

Instantly share code, notes, and snippets.

View odoe's full-sized avatar
👽
It's full of stars

Rene Rubalcava odoe

👽
It's full of stars
View GitHub Profile
const fetchResult = commandFactory<Item>(async ({ path, payload }) => {
const response = await fetch(payload.value);
const result = await response.json();
return [replace(path("result"), JSON.stringify(result, undefined, 2))];
});
const fetchItems = commandFactory<Item>(async ({ path }) => {
const response = await fetch("https://swapi.co/api/");
const json = await response.json();
const items: Item[] = Object.keys(json).map(key => {
return {
label: key,
value: json[key]
};
});
return [replace(path("items"), items)];
import {
createProcess,
createCommandFactory
} from "@dojo/framework/stores/process";
import { replace } from "@dojo/framework/stores/state/operations";
import { State, Item } from "../interfaces";
// commandFactory typed to my application state
const commandFactory = createCommandFactory<State>();
import { tsx } from "@dojo/framework/widget-core/tsx";
import { WidgetBase } from "@dojo/framework/widget-core/WidgetBase";
import { watch } from "@dojo/framework/widget-core/decorators/watch";
import Listbox from "@dojo/widgets/listbox";
import TextArea from "@dojo/widgets/text-area";
import theme from "@dojo/themes/dojo";
import * as css from "./styles/APIExplorer.m.css";
import { ExplorerProperties, Item } from "../interfaces";
export default class Map extends WidgetBase<MapProperties> {
onAttach() {
const element = this.meta(HtmlMeta).get("elemRef") as HTMLElement;
this.properties.initializeMap(element);
}
protected render() {
return <div classes={css.root} key="elemRef" />;
}
}
initializeMap = async (container: HTMLElement) => {
loadCss('https://js.arcgis.com/4.10/esri/css/main.css');
const [MapView, WebMap] = await loadModules(['esri/views/MapView', 'esri/WebMap']);
// then we load a web map from an id
const webmap = new WebMap({
portalItem: {
id: this.webmapid
}
});
// and we show that map in a container w/ id #viewDiv
{
"build-app": {
"build-time-render": {
"root": "root",
"paths": [
"#home",
"#about",
"#profile"
]
}
<!DOCTYPE html>
<html lang="en-us">
<head>
<title>dojo-btr</title>
<meta name="theme-color" content="#222127">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div id="root"></div> <!-- Add this element -->
</body>
// src/widgets/SearchInput.tsx
...
export class SearchInput extends WidgetBase<SearchInputProperties> {
@watch() private searchValue = "";
private onChange(value) {
if (!value) {
return;
}
this.searchValue = value;
const { handleChange } = this.properties;
// src/widgets/EmojiResultsRow.tsx
import { tsx } from "@dojo/framework/widget-core/tsx";
import { WidgetBase } from "@dojo/framework/widget-core/WidgetBase";
import * as css from "./styles/EmojiResultsRow.m.css";
import ElementMeta from "./ElementMeta";
import * as Clipboard from "clipboard";
export interface EmojiResultsRowProperties {
title: string;
symbol: string;
}