Skip to content

Commit

Permalink
Feature enforcement prop support (#16)
Browse files Browse the repository at this point in the history
* Enable support for `requiredFeatures` jsdoc decorator

* update schema, bump schema versions in all packages and publish

* add feature tooltip support

* prerelease bumps

* published pre-releases

* fix featureTooltip to read string values

* go back to base versions as prep for changesets

* bring schema version back to base for changesets

* changesets

* changeset for bumped packages

* Steps for publishing with changesets

* Remove patch changeset file and align package versions

* use experimental flag for internal dependent updates

---------

Co-authored-by: Sam Beveridge <[email protected]>
  • Loading branch information
Locrian24 and 00salmon authored Jun 26, 2024
1 parent f6e0c9d commit cae0203
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 11 deletions.
5 changes: 4 additions & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
"ignore": [],
"___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
"updateInternalDependents": "always"
}
}
6 changes: 6 additions & 0 deletions .changeset/strong-readers-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@raisins/stencil-docs-target": minor
"@raisins/schema": minor
---

Added support for feature enforcement tags on components
9 changes: 8 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,11 @@

## Publishing

- Deploys are done manually for each package with independent versioning.
Deploys are managed with [changesets]

- Use `npx changeset` to add a changeset entry describing a change made.
- _Be sure to mark any packages relying on the changed package to have a `patch` bump. If a package does not have a changeset, it will not get a version bump._
- Run `npx changeset version` to preview the updates that will occur.
- __Do not commit this preview. The automatic PR will take care of this when it is time to publish.__
- Once everything looks good, changes will be merged to the `main` branch, and an automatic PR will be created by changesets.
- Merging this automatic PR will officially update all package versions appropriately and publish the necessary packages.
13 changes: 7 additions & 6 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"typescript": "^3.9.10"
},
"dependencies": {
"@raisins/schema": "^1.0.0",
"@raisins/schema": "^1.0.1",
"color2k": "^2.0.0",
"css": "^3.0.0",
"css-select": "^5.1.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@
}
],
"dependencies": {
"@storybook/cli": "^7.0.21",
"@raisins/core": "^1.1.3",
"@raisins/schema": "^1.0.0",
"@raisins/schema": "^1.0.1",
"bunshi": "~2.0.2",
"css-tree": "^1.1.3",
"fast-equals": "^5.0.1",
Expand Down
20 changes: 20 additions & 0 deletions packages/schema/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ export interface CustomElement {
*/
exampleGroup?: string;

/**
* Array of meaningful tags to enforce feature use within the raisins editor
*/
requiredFeatures?: string[];

/**
* Text to display in a tooltip when the element is disabled due to feature enforcement.
*/
featureTooltip?: string;

/**
* States for previewing the internal state of components
*/
Expand Down Expand Up @@ -208,6 +218,16 @@ export interface Attribute {
* If required is set to true this attribute must not be undefined.
*/
required?: boolean;

/**
* Array of meaningful tags to enforce feature use within the raisins editor.
*/
requiredFeatures?: string[];

/**
* Text to display in a tooltip when the attribute is disabled due to feature enforcement.
*/
featureTooltip?: string;
}

export interface ComponentState {
Expand Down
2 changes: 1 addition & 1 deletion packages/stencil-docs-target/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@
},
"homepage": "https://github.com/saasquatch/raisins",
"dependencies": {
"@raisins/schema": "1.0.1"
"@raisins/schema": "^1.0.1"
}
}
4 changes: 4 additions & 0 deletions packages/stencil-docs-target/src/convertToRaisins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export function convertToGrapesJSMeta(docs: JsonDocs): schema.Module {
// uiGroupSwitch: tagValue(p.docsTags, 'uiGroupSwitch'),
uiOrder: jsonTagValue(p, 'uiOrder'),
required: required(p),
requiredFeatures: jsonTagValue(p, 'requiredFeatures'),
featureTooltip: tagValue(p.docsTags, 'featureTooltip'),
};

return attr;
Expand All @@ -60,6 +62,8 @@ export function convertToGrapesJSMeta(docs: JsonDocs): schema.Module {
title: uiName(comp) ?? comp.tag,
slots: jsonTagValue(comp, 'slots') as schema.Slot[],
attributes,
requiredFeatures: jsonTagValue(comp, 'requiredFeatures'),
featureTooltip: tagValue(comp.docsTags, 'featureTooltip'),
exampleGroup: tagValue(comp.docsTags, 'exampleGroup'),
examples: comp.docsTags
.filter(d => d.name === 'example')
Expand Down

0 comments on commit cae0203

Please sign in to comment.