Skip to content

Commit

Permalink
update Block to include example group to allow more advanced examples
Browse files Browse the repository at this point in the history
  • Loading branch information
00salmon committed Oct 25, 2024
1 parent 983c776 commit a1d5272
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 22 deletions.
59 changes: 47 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@raisins/core",
"author": "ReferralSaaSquatch.com, Inc.",
"description": "Core functions for manipulating and validating HTML and raisin nodes",
"version": "1.1.4",
"version": "1.1.5-1",
"license": "MIT",
"main": "dist/index.js",
"module": "dist/core.esm.js",
Expand Down Expand Up @@ -73,7 +73,7 @@
"typescript": "^3.9.10"
},
"dependencies": {
"@raisins/schema": "^1.1.0",
"@raisins/schema": "^1.1.1-0",
"color2k": "^2.0.0",
"css": "^3.0.0",
"css-select": "^5.1.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@raisins/react",
"author": "ReferralSaaSquatch.com, Inc.",
"description": "React package with tools for building a Raisins editor",
"version": "1.3.0",
"version": "1.3.1-3",
"license": "MIT",
"main": "dist/index.js",
"module": "dist/react.esm.js",
Expand Down Expand Up @@ -55,8 +55,8 @@
}
],
"dependencies": {
"@raisins/core": "^1.1.4",
"@raisins/schema": "^1.1.0",
"@raisins/core": "^1.1.5-1",
"@raisins/schema": "^1.1.1-0",
"@storybook/cli": "^7.0.21",
"bunshi": "~2.0.2",
"css-tree": "^1.1.3",
Expand Down
3 changes: 3 additions & 0 deletions packages/react/src/component-metamodel/ComponentModel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export const ComponentModelMolecule = molecule(
return {
title: block.title,
content: blockFromHtml(block.examples?.[0]?.content as string),
exampleGroup: block.exampleGroup,
};
}) as Block[];
return [...blocksFromModules, ...defaultBlocks];
Expand Down Expand Up @@ -328,6 +329,7 @@ function group(list: Block[], getComponentMeta: Function): BlockGroups {
return list.reduce(function(allGroups: BlockGroups, block: Block) {
const exampleGroup =
getComponentMeta(block.content?.tagName)?.exampleGroup ??
block.exampleGroup ??
DEFAULT_BLOCK_GROUP;
const groupArray = allGroups[exampleGroup] ?? [];
const withBlock = [...groupArray, block];
Expand All @@ -344,6 +346,7 @@ function group(list: Block[], getComponentMeta: Function): BlockGroups {
export type Block = {
title: string;
content: RaisinElementNode;
exampleGroup?: string;
};

export type ComponentModel = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ModuleDetails } from '../types';
/**
* Converts module details into a set of `Block`
*
* Blocks are used for inserting example content into Raisin
* Blocks are used for inserting example content into Raisins
*
* @param moduleDetails
* @returns
Expand Down Expand Up @@ -40,6 +40,7 @@ function reduceExamples(
const blockExample = {
title: currentValue.title,
content: elm,
exampleGroup: currentValue.exampleGroup,
};
return [...previousValue, blockExample];
}
Expand Down
2 changes: 1 addition & 1 deletion packages/schema/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@raisins/schema",
"version": "1.1.0",
"version": "1.1.1-0",
"description": "Types (a.k.a. schema) for the Raisins ecosystem",
"author": "ReferralSaaSquatch.com, Inc.",
"license": "MIT",
Expand Down
1 change: 1 addition & 0 deletions packages/schema/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface Package {
export type Example = {
title: string;
content: string;
exampleGroup?: string;
};

// Custom element modules
Expand Down
4 changes: 2 additions & 2 deletions packages/stencil-docs-target/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@raisins/stencil-docs-target",
"description": "A custom docs target for Stencil components. Edit in Raisins.",
"version": "1.1.0",
"version": "1.1.1-0",
"license": "MIT",
"author": "ReferralSaaSquatch.com, Inc.",
"module": "dist/stencil-docs-target.esm.js",
Expand Down Expand Up @@ -66,6 +66,6 @@
},
"homepage": "https://github.com/saasquatch/raisins",
"dependencies": {
"@raisins/schema": "^1.1.0"
"@raisins/schema": "^1.1.1-0"
}
}
3 changes: 2 additions & 1 deletion packages/stencil-docs-target/src/convertToRaisins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,13 @@ export function convertToGrapesJSMeta(docs: JsonDocs): schema.Module {
const [title, content] = splitOnFirst(d.text ?? '', ' - ');
if (!title || !content) {
throw new Error(
`Invalid example om ${comp.tag} is missing a title or content`
`Invalid example on ${comp.tag} is missing a title or content`
);
}
return {
title,
content,
exampleGroup: tagValue(comp.docsTags, 'exampleGroup'),
};
}),
demoStates: demos.length > 0 ? demos : undefined,
Expand Down

0 comments on commit a1d5272

Please sign in to comment.