diff --git a/.commitlintrc.json b/.commitlintrc.json new file mode 100644 index 0000000000..6401e2c3dd --- /dev/null +++ b/.commitlintrc.json @@ -0,0 +1,5 @@ +{ + "rules": { + "scope-case": [2, "always", ["lower-case", "pascal-case", "camel-case"]] + } +} diff --git a/packages/react/src/components/design-system.tsx b/packages/react/src/components/design-system.tsx new file mode 100644 index 0000000000..ba7aaa1894 --- /dev/null +++ b/packages/react/src/components/design-system.tsx @@ -0,0 +1,16 @@ +import React, { FunctionComponent } from 'react'; +import { DeviceContextProvider, DeviceContextProviderProps } from './device-context-provider/device-context-provider'; +import { IntlProvider, IntlProviderProps } from './internationalization-provider/internationalization-provider'; +import { ThemeWrapper, ThemeWrapperProps } from './theme-wrapper/theme-wrapper'; + +export type DesignSystemProps = ThemeWrapperProps & DeviceContextProviderProps & IntlProviderProps; + +export const DesignSystem: FunctionComponent = (props) => ( + + + + {props.children} + + + +); diff --git a/packages/react/src/components/device-context-provider/device-context-provider.tsx b/packages/react/src/components/device-context-provider/device-context-provider.tsx index c52a866926..ea76327a1a 100644 --- a/packages/react/src/components/device-context-provider/device-context-provider.tsx +++ b/packages/react/src/components/device-context-provider/device-context-provider.tsx @@ -1,10 +1,9 @@ -import React, { createContext, ReactElement, ReactNode, useContext, useEffect, useState } from 'react'; +import React, { createContext, FunctionComponent, useContext, useEffect, useState } from 'react'; import { breakpoints, Breakpoints } from '../../tokens/breakpoints'; export type DeviceType = 'desktop' | 'tablet' | 'mobile'; -interface Props { - children: ReactNode; +export interface DeviceContextProviderProps { staticDevice?: DeviceType; } @@ -63,7 +62,7 @@ const getDevice = (screenWidth: number): DeviceType => { const DeviceContext = createContext(getDeviceContext()); -export const DeviceContextProvider = ({ children, staticDevice }: Props): ReactElement => { +export const DeviceContextProvider: FunctionComponent = ({ children, staticDevice }) => { const [device, setDevice] = useState(getDeviceContext(staticDevice)); function handleScreenResize(): void { diff --git a/packages/react/src/components/internationalization-provider/internationalization-provider.tsx b/packages/react/src/components/internationalization-provider/internationalization-provider.tsx index 135ae0a83c..97ab57a959 100644 --- a/packages/react/src/components/internationalization-provider/internationalization-provider.tsx +++ b/packages/react/src/components/internationalization-provider/internationalization-provider.tsx @@ -1,9 +1,8 @@ import { i18n as i18nType } from 'i18next'; -import React, { createContext, ReactElement, useContext, useEffect, useState } from 'react'; +import React, { createContext, FunctionComponent, useContext, useEffect, useState } from 'react'; import { createI18n } from '../../i18n/i18n'; -interface IntlProviderProps { - children: ReactElement; +export interface IntlProviderProps { language?: string; } @@ -13,7 +12,7 @@ interface IntlContextProps { const IntlContext = createContext({ i18n: createI18n() }); -export function IntlProvider({ children, language }: IntlProviderProps): ReactElement { +export const IntlProvider: FunctionComponent = ({ children, language }) => { const [i18n] = useState(createI18n); useEffect(() => { @@ -28,7 +27,7 @@ export function IntlProvider({ children, language }: IntlProviderProps): ReactEl {children} ); -} +}; export function useIntlContext(): IntlContextProps { return useContext(IntlContext); diff --git a/packages/react/src/components/theme-wrapper/theme-wrapper.tsx b/packages/react/src/components/theme-wrapper/theme-wrapper.tsx index b87a2cc936..0a43e762cf 100644 --- a/packages/react/src/components/theme-wrapper/theme-wrapper.tsx +++ b/packages/react/src/components/theme-wrapper/theme-wrapper.tsx @@ -1,15 +1,15 @@ -import React, { ReactElement, ReactNode } from 'react'; -import { ThemeProvider, ThemeProviderProps } from 'styled-components'; +import React, { FunctionComponent, ReactNode } from 'react'; +import { ThemeProvider } from 'styled-components'; import { useStyle } from '../../styles'; import { equisoftTheme, Theme } from '../../themes'; import { ShadowWrapper } from '../shadow-wrapper/shadow-wrapper'; -interface ThemeWrapperProps extends Omit, 'theme'> { +export interface ThemeWrapperProps { isolateStyles?: boolean; theme?: Theme; } -export function ThemeWrapper({ children, isolateStyles = false, theme }: ThemeWrapperProps): ReactElement { +export const ThemeWrapper: FunctionComponent = ({ children, isolateStyles = false, theme }) => { let selectedTheme = theme; if (selectedTheme) { if (Object.entries(selectedTheme).length === 0 && selectedTheme.constructor === Object) { @@ -33,4 +33,4 @@ export function ThemeWrapper({ children, isolateStyles = false, theme }: ThemeWr {content} ); -} +}; diff --git a/packages/react/src/index.ts b/packages/react/src/index.ts index bd6ff55b94..aeb4ec674e 100644 --- a/packages/react/src/index.ts +++ b/packages/react/src/index.ts @@ -68,3 +68,5 @@ export { Pagination } from './components/pagination/pagination'; export { equisoftTheme } from './themes/equisoft'; export { testTheme } from './themes/test-theme'; export { injectMainCss } from './styles'; + +export * from './components/design-system';