Author:
Fluent Commerce
Changed on:
8 July 2024
Getting Started Guide for Component SDK
The latest version of the SDK can be downloaded here.
Before using the SDK you should have the following software installed and available on your machine:
The SDK then makes several common libraries available in the global scope so that developers can keep their plugins nice and light. These dependencies are already marked as available at runtime in the build configurations provided in the sample project.
These are:
The Component SDK provides a standard React / Typescript project that can be extended to develop new components.
`mystique-plugin-acme`
`$ git init`
`$ yarn install`
`$ yarn start`
1{
2 "plugins":[{ "src": "http://localhost:3001/bundle.js" }],
3 "routes": [
4 { "path":"hello", "component":"fc.hello" }
5 ]
6}
Language: json
Name: Sample Manifest using a custom Plugin
Description:
[Warning: empty required content area]There are two options when adding a plugin to your manifest. You can:
`{ "src": "http://myhost.com/myplugin/bundle.js" }`
`{ "src": "http://myhost.com/myplugin/" }`
In the folder case the framework will first check for a
`version.json`
The
`version.json`
`v`
`http://myhost.com/myplugin/version.json?v=1628209170000`
1{
2 "bundle": "bundle.8d2c4b9aebdc9b502b32.js"
3}
Language: json
Name: The structure of this file is simply:
Description:
[Warning: empty required content area]Where the hash value would come from a Webpack
`contenthash`
This gives SDK developers the ability to:
While most Javascript libraries should be usable in plugins, there are some best practice guidelines to keep in mind.
The UX Framework (aka Mystique) is based on ReactJS, so always prefer React-based libraries when possible.
The standard library of Fluent components are all based on the Material UI framework.
Any Fluent hooks used in a component should generally be mocked in corresponding unit tests.
This can be done by: 1. importing with a wildcard at the module level 1. using
`Jest.spyOn`
For example, a simple version of mocking the
`useI18n()`
1import * as UseI18n from 'mystique/hooks/useI18n';
2
3const i18nValues: any = {
4 'fc.test.a': 'Test Value 1',
5};
6
7describe('Tests that require translation of strings', () => {
8
9 beforeEach(() => {
10 jest.spyOn(UseI18n, 'useI18n').mockImplementation(() => ({
11 translate: (key: string) => i18nValues[key]
12 }));
13 });
14
15 // tests go here...
16});
Language: typescript
Name: Example
Description:
[Warning: empty required content area]Consult the hook interface documentation in the
`@types`
Copyright © 2024 Fluent Retail Pty Ltd (trading as Fluent Commerce). All rights reserved. No materials on this docs.fluentcommerce.com site may be used in any way and/or for any purpose without prior written authorisation from Fluent Commerce. Current customers and partners shall use these materials strictly in accordance with the terms and conditions of their written agreements with Fluent Commerce or its affiliates.