Skip to content

Instantly share code, notes, and snippets.

💭
It's full of stars

Rene Rubalcava odoe

💭
It's full of stars
Block or report user

Report or block odoe

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View typescript.snippets
snippet dtsx "Dojo tsx widget"
import { create, tsx } from '@dojo/framework/core/vdom';
const factory = create();
export default factory(function $1() {
return (
<div>Widget</div>
);
});
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
<title>My First Map</title>
<style>
html,
body,
#viewDiv {
View .vimrc
" minpac package manager
" Try to load minpac.
packadd minpac
if !exists('*minpac#init')
" minpac is not available.
" Settings for plugin-less environment.
" ...
else
View Profile.ts
// src/tests/unit/widgets/Profile.ts
describe("Profile", () => {
it("default renders correctly", () => {
const h = harness(() => w(Profile, {}));
h.expect(profileAssertion);
});
it("renders given username correctly", () => {
// update the expected result with a given username
const namedAssertion = profileAssertion.setChildren("~welcome", [
"Welcome Kel Varnsen!"
View Profile.ts
// tests/unit/widgets/Profile.ts
// Add the assertionTemplate module
import assertionTemplate from "@dojo/framework/testing/assertionTemplate";
...
// Create my assertion
const profileAssertion = assertionTemplate(() =>
v("h1", { classes: [css.root], "~key": "welcome" }, ["Welcome Stranger!"])
);
describe("Profile", () => {
it("default renders correctly", () => {
View Profile.ts
// src/widgets/Profile.ts
export interface ProfileProperties {
username?: string;
}
export default class Profile extends WidgetBase<ProfileProperties> {
protected render() {
const { username } = this.properties;
return v("h1", { classes: [css.root] }, [
`Welcome ${username || "Stranger"}!`
]);
View Profile.ts
// tests/unit/widgets/Profile.ts
const { describe, it } = intern.getInterface("bdd");
import harness from "@dojo/framework/testing/harness";
import { w, v } from "@dojo/framework/widget-core/d";
import Profile from "../../../src/widgets/Profile";
import * as css from "../../../src/widgets/styles/Profile.m.css";
describe("Profile", () => {
it("default renders correctly", () => {
const h = harness(() => w(Profile, { username: "Dojo User" }));
h.expect(() => v("h1", { classes: [css.root] }, ["Welcome Dojo User!"]));
View imagebase64.block.ts
import { resolve } from 'path';
import { v } from '@dojo/framework/widget-core/d';
import * as sharp from 'sharp';
export default async function (path: string) {
path = resolve(__dirname, path);
// resize my images
const images = [
await sharp(path).resize(200).toBuffer(),
await sharp(path).resize(300).toBuffer(),
await sharp(path).resize(400).toBuffer(),
View AboutWidget.tsx
import WidgetBase from "@dojo/framework/widget-core/WidgetBase";
import { dom } from "@dojo/framework/widget-core/d";
import Block from "@dojo/framework/widget-core/meta/Block";
import { tsx } from "@dojo/framework/widget-core/tsx";
import fromMarkdown from "../blocks/markdown.block";
import * as css from "./styles/About.m.css";
export default class About extends WidgetBase {
protected render() {
const node = document.createElement("div");
// Use my block
View markdown.block.ts
import * as fs from 'fs';
import { resolve } from 'path';
import { Converter } from 'showdown';
const mdConverter = new Converter();
export default function (path: string) {
path = resolve(__dirname, path);
const file = fs.readFileSync(path, 'utf8');
// convert Markdown to HTML
const html = mdConverter.makeHtml(file);
return html
You can’t perform that action at this time.