Skip to content

Instantly share code, notes, and snippets.

import { eq, not } from '@cardstack/boxel-ui/helpers';
// ═══ [EDIT TRACKING: ON] Mark all changes with ⁽ⁿ⁾ ═══
import {
CardDef,
field,
contains,
Component,
} from 'https://cardstack.com/base/card-api'; // ⁽¹⁾ Core imports
import StringField from 'https://cardstack.com/base/string';
import NumberField from 'https://cardstack.com/base/number';
@habdelra
habdelra / mermaid-diagram.gts
Created May 20, 2025 14:49
Idiomatic Boxel Mermaid Card
import {
CardDef,
field,
contains,
Component,
} from 'https://cardstack.com/base/card-api';
import TextAreaField from 'https://cardstack.com/base/text-area';
import { on } from '@ember/modifier';
import { tracked } from '@glimmer/tracking';
import { Button } from '@cardstack/boxel-ui/components';
@habdelra
habdelra / README.txt
Created July 1, 2021 21:09
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.24+commit.e67f0147.js&optimize=true&runs=10&gist=
REMIX EXAMPLE PROJECT
Remix example project is present when Remix loads very first time or there are no files existing in the File Explorer.
It contains 3 directories:
1. 'contracts': Holds three contracts with different complexity level, denoted with number prefix in file name.
2. 'scripts': Holds two scripts to deploy a contract. It is explained below.
3. 'tests': Contains one test file for 'Ballot' contract with unit tests in Solidity.
SCRIPTS
The following cs fields exist on cards:
- csRealm: The realm that the card currently resides in.
- csId: The csId distinguishes the card within its originalRealm. In some cases
it may be chosen by the person creating the card. In others it may be
chosen by the hub.
- csOriginalRealm: The realm that the card was first created in. Often times
this value will be undefined, when this value is undefined that means that the
@habdelra
habdelra / gist:f356040b35b6426c685aa1fbece2cd63
Last active February 6, 2020 19:08
Card Network Requests for Orbit
Card creation
POST http://localhost:3000/api/realms/first-ephemeral-realm/cards
Request Body:
{
"data": {
"type": "cards",
"attributes": {
"csFieldSets": {
"embedded": [
@habdelra
habdelra / data.js
Last active September 23, 2019 21:06
Card Data Service brainstorming
import Service from '@ember/service';
export default class DataService extends Service {
cache = new Map();
async getCard(id /*: string */, format /*: string*/) {
// if the card already exists in the cache, just return cached card
// return Card instance
}
@habdelra
habdelra / Creating a card using JSONAPIFactory
Last active August 7, 2019 16:57
article-card/card.js
// This file lives in an npm module with the name of 'article-card' in a cards.js file.
// (I think just using index.js might be a good idea too--i can go either way here)
const JSONAPIFactory = require('@cardstack/test-support/jsonapi-factory');
module.exports = function() {
let factory = new JSONAPIFactory();
// the card ID specified only needs to speify the last part of the multi-part ID.
// the rest of the card ID parts are derived from the package name.
// In this example we show how fields are actually cards, and we customize a field by adopting a string-field card.
{
data: {
type: 'cards'
id: '@acme/ticket-tools::ticket-card:123',
...
},
included: [
@habdelra
habdelra / gist:f5c519790afdaf24bf371fa71b1fc464
Last active August 5, 2019 17:59
Card Relationship Polymorphism
// In this example we control the types of cards that are allowed in the event relationship
// using the "related-cards" relationship that hangs off of the field.
{
data: {
type: 'cards'
id: '@acme/ticket-tools::ticket-card:123',
...
},
included: [
{
data: {
type: 'cards'
id: '@acme/ticket-tools::ticket-card:123',
attributes: {
'edit-template': `
{{delegate-to content.event}} {{!-- framework decides the format to use, appears as embedded until a user clicks on it, for example --}}
{{delegate-to content.price}}
`,
'isolated-template': `