@kleeen/core-react
Advanced tools
Comparing version 0.1.0-beta.0 to 1.0.0-rc.1
{ | ||
"name": "@kleeen/core-react", | ||
"version": "0.1.0-beta.0", | ||
"description": "kleeen-core-react", | ||
"version": "1.0.0-rc.1", | ||
"description": "Kleeen SDK React core", | ||
"main": "lib/index.js", | ||
@@ -43,4 +43,5 @@ "module": "es/index.js", | ||
"keywords": [ | ||
"kleeen-ui" | ||
"kleeen-ui", | ||
"core" | ||
] | ||
} |
@@ -157,3 +157,3 @@ # kleeen-core-react | ||
### Description | ||
Provider for the internationalization of the application defined in a file with the following structure (localeData): | ||
Provider for the internationalization of the application, it uses a translations object and the structures is: | ||
@@ -171,9 +171,15 @@ ``` | ||
### Properties | ||
the first key means the language, and you need to have a key for each string on your app (or at least the strings that should support multi languages) and that is the second key. | ||
this implementation was done based on `react-intl`[https://github.com/yahoo/react-intl] and its support the mayority of the features as well, because of the way of how the flow of the params is. | ||
### Properties of the translation provider | ||
| Type |Name |Default Values| | ||
| -------|------------- |------------- | | ||
| String |locale|Navigator Languaje| | ||
| Array |languageToSupport|[ es , en , fr , it ]| | ||
| Json |localeData| { }| | ||
| String |languaje|Navigator Languaje|default languaje | ||
| Array |languageToSupport|[ es , en , fr , it ]|specifics int18n cases | ||
| Json |localeData| { }|application strings by languaje | ||
you can send more params and they are going to be added to the `IntlProvider` from `react-int`. | ||
### Init Provider | ||
@@ -189,3 +195,3 @@ ``` | ||
<ThemingConsumer> | ||
<TranslationConsumer> | ||
{({ setLocale }) => ( | ||
@@ -197,4 +203,5 @@ select onChange={e => setLocale(e.target.value)}> | ||
)} | ||
</ThemingConsumer> | ||
</TranslationConsumer> | ||
``` | ||
you can consume the `TranslationConsumer` and change the data of the provider, you can also use the kuiConnect and receive for props the `setLocale` directly. | ||
@@ -205,5 +212,14 @@ ### Use for translation | ||
``` | ||
you can also inject an `translate function` in your props in order to manage the translations with a function, this can be done with the kuiConnect. | ||
``` | ||
<Fragment>{translate({ id: "App.adminText", defaultMessage: "content only for Admin" })}</Fragment> | ||
``` | ||
or | ||
``` | ||
<Fragment>{translate('App.adminText')}</Fragment> | ||
``` | ||
## KUIConnect | ||
It allows to add the consumers of the combine consumer to a component to pass the props and these can be used from that component. | ||
It allows to have access to all the kui providers context much like the redux connect (only in the idea not in the implementation itself) you can decorate a component with the kuiConnect, who receive a mapStateToProps function, the mapStateToProps function dictates the props that are going to be injected to the decorated component (you have access of all the kui providers context that you have in your app). | ||
@@ -227,3 +243,3 @@ ### Example | ||
connect(state => state, ({ logIn })), | ||
KUIConnect(state => state), | ||
KUIConnect(state => state), // injecting all that data of the providers that you have on your app. | ||
)(App); | ||
@@ -238,3 +254,4 @@ ``` | ||
``` | ||
<KUICombineProviders providers = {[ | ||
ReactDOM.render( | ||
<KUICombineProviders providers={[ | ||
TranslationProvider({ localeData, locale: 'en' }), | ||
@@ -244,11 +261,16 @@ ReduxProvider, | ||
]} | ||
> | ||
> | ||
<App /> | ||
</KUICombineProviders>, | ||
document.getElementById('root'), | ||
); | ||
``` | ||
## Combine Consumers | ||
Function that subscribes to context changes. The properties for this function are `children` and `consumers`. | ||
Function that subscribes to context changes. The properties for this function are `children` and `consumers` it should be use like the kuiConnect in a react context way. | ||
### Example | ||
``` | ||
KUICombineConsumers({ | ||
const KUIConsumers = ({ children }) => KUICombineConsumers({ | ||
children, | ||
@@ -261,2 +283,7 @@ consumers: { | ||
}); | ||
<KUIConsumers> | ||
{({ icons, theming, translation }) => ( | ||
{...some use for all the provider context} | ||
)} | ||
</KUIConsumers> | ||
``` | ||
@@ -263,0 +290,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
888246
7786
290