Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@smartface/contx
Advanced tools
You may want to take a look at styler documentation to have a better understanding of how Context works.
Each context encapsulates some behaviors and applies theme to decorated components which are came from outside of the context using Context's actors and reducers.
PageContext creates stylable Smartface pages and components so that we can manipulate them using style-objects and selectors. Smartface UI-Editor Transpiler connects Pages and PageContext. To add components dynamically in runtime, (For instance there might be images that should be created after an api call) PageContext's actions must be used.
When PageContext is initialized for the first time then it creates component view-tree recursively using FlexLayout's children property.
To manipulate Context's states and behaviors, explicitly defined or custom actions must be used so that Context's reducers are triggered.
Action::type = addChild Adds specified component and their children to the PageContext and applies styles by class-name selectors.
Action.type => changeUserStyle : Overwrites component userStyle.
myButton.dispatch({
type: "changeUserStyle",
userStyle: {
backgroundColor: "#AABBCC"
}
});
myButton.dispatch({
type: "changeUserStyle",
userStyle: (style) => {
style.backgroundColor = "#AABBCC";
return style;
}
});
Action.type => updateUserStyle : Updates component userStyle.
myButton.dispatch({
type: "updateUserStyle",
userStyle: {
backgroundColor: "#AABBCC"
}
});
Action.type => removeChild : Removes target component and it's children from context.
myLayout.dispatch({
type: "removeChild"
});
Action.type => removeChildren : Removes target component's children from context.
myLayout.dispatch({
type: "removeChildren"
});
Action.type => pushClassNames : Pushes new className selectors to the target component.
myButton.dispatch({
type: "pushClassNames",
classNames: [".foo", ".bar"]
});
myButton.dispatch({
type: "pushClassNames",
classNames: ".foo"
});
Action.type => removeClassName : Removes className selector from specified component.
myButton.dispatch({
type: "removeClassName",
className: [".foo", ".bar"]
});
myButton.dispatch({
type: "removeClassName",
className: ".foo"
});
Action.type => invalidate : Forces to update Context's actors and applies styles if they are changed.
myButton.dispatch({
type: "invalidate"
});
Action.type => updateContext : Adds new components to Context or removes ones that doesn't exist in the updated FlexLayout::children.
Adds specified component to target layout and if contextName is specified then dispatches addPageContextChild action to the Context.
var myButton = new Button();
page.layout.addChild(myButton, "myButton", ".button", {
width: 250,
height: 250
});
or
page.layout.addChild(myButton, "myButton", ".button", function(userProps) {
userProps.width = 250;
userProps.height = 250;
return userProps;
});
Removes specified component from target layout then dispatches removeChild action to the Context.
// myButton component will be removed from both context and page layout
page.layout.removeChild(myButton);
Removes target component's children then dispatches removeChildren action to the Context.
// Children of page will be removed from both context and page layout
page.layout.removeAll();
When a component is removed from the Context and if the component has componentDidLeave method then it's triggered.
When a component initialized in the Context and if the component has componentDidEnter method and then it's triggered by passing it's dispatch method. If not, dispatch method will be assigned to component directly.
If an error occcurs while an operation is being performed for a component, for example assignment of new properties, and the component has onError method then the error is passed to onError method of the component. If not and then the context throws the error.
It is possible to change the current theme without the need to reload.
const Application = require("sf-core/application");
// Seamlessly switch between themes
Application.theme()({ type: "changeTheme", theme: "yourThemeName" });
Component instances created via code are not connected to the context. Therefore they don't have dispatch method for updating user styles & classes. In order to prevent that, components must be connected to the context manually. Please see the following example.
const componentContextPatch = require("@smartface/contx/lib/smartface/componentContextPatch");
let dialog = new Dialog();
let flWait = new FlWait(); // A library component
componentContextPatch(dialog, `dialog`); // Connect component to context
dialog.layout.addChild(flWait, `flWait`, ".flWait"); // Child components are connected autmatically
dialog.layout.applyLayout();
dialog.show();
Some properties are called attributes. Context does not handle attribute properties.
If you want to set an attribute, just set it directly like below:
button.text = "Text";
FAQs
Context Manager
The npm package @smartface/contx receives a total of 23 weekly downloads. As such, @smartface/contx popularity was classified as not popular.
We found that @smartface/contx demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.