Skip to content

Instantly share code, notes, and snippets.

View josemarluedke's full-sized avatar

Josemar Luedke josemarluedke

View GitHub Profile
import { getOwner } from '@ember/application';
import type RouterService from '@ember/routing/router-service';
function useService<T = unknown>(ctx: object, name: string): T {
return getOwner(ctx).lookup(`service:${name}`) as T;
}
function ref<T = unknown>(initialValue: T): Ref<T> {
return new Ref<T>(initialValue);
}
const Docfy = require('@docfy/core');
const getConfig = require('@docfy/ember/lib/get-config').default;
const config = getConfig(__dirname);
(async function () {
const docfy = new Docfy(config);
const result = await docfy.run(config.sources);
let totalDemoComponents = 0;
import ApolloService from 'ember-apollo-client/services/apollo';
import { tracked } from '@glimmer/tracking';
import { resource } from 'ember-usable';
import { inject as service } from '@ember/service';
import { getOwner } from '@ember/application';
import {
ApolloQueryResult,
NetworkStatus,
OperationVariables,
DocumentNode,
import ApolloService from 'ember-apollo-client/services/apollo';
import { persistCache } from 'apollo-cache-persist';
class OverriddenApollo extends ApolloService {
async init() {
await persistCache({
this.cache(),
storage: window.localStorage,
});
@josemarluedke
josemarluedke / ember-cil-build.js
Created April 12, 2020 00:34
Ember + TailwindCSS + PurgeCSS + CSS Modules
'use strict';
const EmberApp = require('ember-cli/lib/broccoli/ember-app');
const env = EmberApp.env();
const purgecssOptions = {
content: ['./app/index.html', './app/**/*.hbs', './node_modules/**/*.hbs'],
defaultExtractor: (content) => {
return content.match(/[A-Za-z0-9-_:/]+/g) || [];
},
import ApplicationInstance from '@ember/application/instance';
export function initialize(appInstance: ApplicationInstance): void {
const fastboot = appInstance.lookup('service:fastboot');
const apolloCache = appInstance.lookup('service:apollo').client.cache;
const shoebox = fastboot.get('shoebox');
if (fastboot.get('isFastBoot')) {
shoebox.put('apollo-cache', {
get cache(): unknown {
const visit = require('unist-util-visit');
const escapeHBS = node => {
if(!node.value) {
return;
}
if (((/^({{|<[A-Z]|<\/[A-Z])/g)).test(node.value)) {
node.type = 'html';
}
}
app
├── app.js
├── authenticated-route.ts
├── authenticators
│ ├── oauth2-authorization-code.ts
│ └── oauth2-password.ts
├── breakpoints.js
|── components
│   ├── change-password-form
│   │   ├── index.ts
app
├── app.js
├── authenticated-route.ts
├── authenticators
│   ├── oauth2-authorization-code.ts
│   └── oauth2-password.ts
├── breakpoints.js
├── config
│   └── environment.d.ts
├── helpers

<ChangesetForm>

The <ChangesetForm> component binds an instance of ember-changeset to a <form> tag. This binding is achieved through the component's {{yield}}, which is a hash of form controls that interface with the underlying changeset object.

Here's a list of yielded form components,

Hash Name Component
Text <InputText>
Textarea ``