How to use the @dojo/framework/core/mixins/Themed.theme function in @dojo/framework

To help you get started, we’ve selected a few @dojo/framework examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dojo / widgets / src / slider / index.tsx View on Github external
showOutput?: boolean;
	/** Size of the slider increment */
	step?: number;
	/** If the value provided by the slider are valid */
	valid?: boolean;
	/** The current value */
	value?: number;
	/** Orients the slider vertically, false by default. */
	vertical?: boolean;
	/** Length of the vertical slider (only used if vertical is true) */
	verticalHeight?: string;
	/** The id used for the form input element */
	widgetId?: string;
}

@theme(css)
export class Slider extends ThemedMixin(FocusMixin(WidgetBase)) {
	// id used to associate input with output
	private _widgetId = uuid();

	private _onInput(event: Event) {
		event.stopPropagation();
		const value = (event.target as HTMLInputElement).value;

		this.properties.onValue && this.properties.onValue(parseFloat(value));
	}

	protected getRootClasses(): (string | null)[] {
		const { disabled, valid, readOnly, vertical = false } = this.properties;
		const focus = this.meta(Focus).get('root');

		return [
github dojo / widgets / src / combobox / index.tsx View on Github external
results?: any[];
	/** Determines if this input is valid */
	valid?: { valid?: boolean; message?: string } | boolean;
	/** Value to set on the input */
	value?: string;
	/** Optional id string for the combobox, set on the text input */
	widgetId?: string;
}

// Enum used when traversing items using arrow keys
export enum Operation {
	increase = 1,
	decrease = -1
}

@theme(css)
@diffProperty('results', reference)
export class ComboBox extends I18nMixin(ThemedMixin(FocusMixin(WidgetBase))) {
	private _activeIndex = 0;
	private _ignoreBlur: boolean | undefined;
	private _idBase = uuid();
	private _menuHasVisualFocus = false;
	private _open: boolean | undefined;
	private _wasOpen: boolean | undefined;

	private _closeMenu() {
		this._open = false;
		this.invalidate();
	}

	private _getMenuId() {
		return `${this._idBase}-menu`;
github dojo / widgets / src / grid / PlaceholderRow.tsx View on Github external
import WidgetBase from '@dojo/framework/core/WidgetBase';
import { v } from '@dojo/framework/core/vdom';
import ThemedMixin, { theme } from '@dojo/framework/core/mixins/Themed';
import { DNode } from '@dojo/framework/core/interfaces';
import * as css from '../theme/default/grid-placeholder-row.m.css';

@theme(css)
export default class PlaceholderRow extends ThemedMixin(WidgetBase) {
	protected render(): DNode {
		return v('div', { classes: this.theme(css.root) }, [
			v('div', { classes: this.theme(css.loading) })
		]);
	}
}
github dojo / widgets / src / text-area / index.tsx View on Github external
readOnly?: boolean;
	/** Sets the input as required to complete the form */
	required?: boolean;
	/** Number of rows, controls the height of the textarea */
	rows?: number;
	/** If the field is valid and optionally display a message */
	valid?: { valid?: boolean; message?: string } | boolean;
	/** The current value */
	value?: string;
	/** The id used for the form input element */
	widgetId?: string;
	/** Controls text wrapping. Can be "hard", "soft", or "off" */
	wrapText?: 'hard' | 'soft' | 'off';
}

@theme(css)
export class TextArea extends ThemedMixin(FocusMixin(WidgetBase)) {
	private _dirty = false;

	private _onInput(event: Event) {
		event.stopPropagation();
		this.properties.onValue &&
			this.properties.onValue((event.target as HTMLInputElement).value);
	}

	private _onKeyDown(event: KeyboardEvent) {
		event.stopPropagation();
		this.properties.onKeyDown &&
			this.properties.onKeyDown(event.which, () => {
				event.preventDefault();
			});
	}
github dojo / widgets / src / grid / PaginatedBody.ts View on Github external
updater: (page: number, rowNumber: number, columnId: string, value: string) => void;
	/** Handler for scroll events */
	onScroll: (value: number) => void;
	/** Calculated column widths */
	columnWidths?: { [index: string]: number };
	/** handler for row selection */
	onRowSelect?: (index: number, type: SelectionType) => void;
	/** array of selected rows */
	selectedRows?: number[];
}

const defaultPlaceholderRowRenderer = (index: number) => {
	return w(PlaceholderRow, { key: index });
};

@theme(css)
@diffProperty('pages', reference)
export default class PaginatedBody<s> extends ThemedMixin(WidgetBase)&gt; {
	private _updater(rowNumber: number, columnId: string, value: any) {
		const page = Math.max(Math.ceil(rowNumber / this.properties.pageSize), 1);
		const pageItemNumber = rowNumber - (page - 1) * this.properties.pageSize;
		this.properties.updater(page, pageItemNumber, columnId, value);
	}

	private _onScroll(event: UIEvent) {
		const scrollLeft = (event.target as HTMLElement).scrollLeft;
		this.properties.onScroll(scrollLeft);
	}

	private _renderRows() {
		const {
			pageSize,</s>
github dojo / widgets / src / label / index.tsx View on Github external
forId?: string;
	/** If the label should be invisible (it will remain accessible to screen readers) */
	hidden?: boolean;
	/** If the label is read only */
	readOnly?: boolean;
	/** If the label is required */
	required?: boolean;
	/** If the label should use the secondary styling */
	secondary?: boolean;
	/** If the label is valid */
	valid?: boolean;
	/** ID of the underlying label element */
	widgetId?: string;
}

@theme(css)
export class Label extends ThemedMixin(WidgetBase) {
	protected getRootClasses(): (string | null)[] {
		const { disabled, focused, valid, readOnly, required, secondary } = this.properties;
		return [
			css.root,
			disabled ? css.disabled : null,
			focused ? css.focused : null,
			valid === true ? css.valid : null,
			valid === false ? css.invalid : null,
			readOnly ? css.readonly : null,
			required ? css.required : null,
			secondary ? css.secondary : null
		];
	}

	render(): DNode {
github dojo / widgets / src / grid / Footer.tsx View on Github external
import { v } from '@dojo/framework/core/vdom';
import ThemedMixin, { theme } from '@dojo/framework/core/mixins/Themed';
import { DNode } from '@dojo/framework/core/interfaces';

import * as css from '../theme/default/grid-footer.m.css';

export interface FooterProperties {
	/** The total number of rows */
	total?: number;
	/** The current page */
	page: number;
	/** The number of rows per page */
	pageSize: number;
}

@theme(css)
export default class Footer extends ThemedMixin(WidgetBase) {
	protected render(): DNode {
		const { total, page, pageSize } = this.properties;
		const footer =
			total !== undefined
				? `Page ${page} of ${Math.ceil(total / pageSize)}. Total rows ${total}`
				: `Page ${page} of ?`;
		return v('div', { classes: this.theme(css.root) }, [footer]);
	}
}
github dojo / examples / custom-element-menu / src / widgets / MenuItem.ts View on Github external
import * as css from './styles/menuItem.m.css';

export interface MenuItemProperties {
	selected?: boolean;
	data?: any;
	title?: string;
	onSelected?: (data: any) =&gt; void;
}

@customElement({
	tag: 'demo-menu-item',
	events: ['onSelected'],
	attributes: ['title'],
	properties: ['data', 'selected']
})
@theme(css)
export class MenuItem extends ThemedMixin(WidgetBase) {
	private _onClick() {
		this.properties.onSelected &amp;&amp; this.properties.onSelected(this.properties.data);
	}

	protected render() {
		const { selected } = this.properties;

		return v('li', { classes: this.theme(css.root) }, [
			v(
				'span',
				{
					classes: this.theme([css.item, selected ? css.selected : null]),
					onclick: this._onClick
				},
				[this.properties.title]
github dojo / widgets / src / grid / Cell.tsx View on Github external
import * as css from '../theme/default/grid-cell.m.css';

export interface CellProperties extends FocusProperties {
	/** The display value (or widget) of the cell */
	value: string | DNode;
	/** If the cell's value may be updated */
	editable?: boolean;
	/** The underlying string value of the cell (used by the editor) */
	rawValue: string;
	/** Called when the Cell's value is saved by the editor */
	updater: (value: any) =&gt; void;
	/** The width (in pixels) */
	width?: number;
}

@theme(css)
export default class Cell extends ThemedMixin(FocusMixin(WidgetBase)) {
	private _editing = false;
	private _editingValue = '';
	private _focusKey!: string;
	private _idBase = uuid();

	private _callFocus(key: string) {
		this._focusKey = key;
		this.focus();
	}

	private _onEdit = () =&gt; {
		const { editable } = this.properties;
		if (editable) {
			this._editing = true;
			this._callFocus('input');
github dojo / widgets / src / grid / index.tsx View on Github external
updater?: Updater<s>;
	/** options store, if no store is passed each grid will factory their own grid */
	store?: Store<s>;
	/** the path to store the grid data in */
	storeId?: string;
	/** set of custom renderers for sorting or filtering */
	customRenderers?: CustomRenderers;
	/** when set uses traditional pagination */
	pagination?: boolean;
	/** handler for row selection */
	onRowSelect?: (rowData: S[]) =&gt; void;
}

const MIN_COLUMN_WIDTH = 100;

@theme(css)
export default class Grid<s> extends ThemedMixin(WidgetBase)&gt; {
	private _store = new Store&gt;();
	private _handle: any;
	private _scrollLeft = 0;
	private _pageSize = 100;
	private _columnWidths: { [index: string]: number } | undefined;
	private _gridWidth = 0;

	constructor() {
		super();
		this._handle = this._store.onChange(this._store.path('_grid'), this.invalidate.bind(this));
	}

	@diffProperty('store', reference)
	protected onStoreProperty(previous: any, current: any) {
		const { storeId = '_grid' } = current;</s></s></s>