-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
218 additions
and
85 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
.../commercetools-frontend-application-shell-connectors/get-project-extension-image-regex.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { | ||
GetProjectExtensionImageRegex, | ||
ProjectExtensionProviderForImageRegex, | ||
} from '@commercetools-frontend/application-shell-connectors'; | ||
|
||
function MyComponent() { | ||
return ( | ||
<GetProjectExtensionImageRegex | ||
render={({ isLoading, imageRegex }) => { | ||
if (isLoading) return <LoadingSpinner />; | ||
|
||
return ( | ||
<div> | ||
<h1>Project images regex: {imageRegex}</h1> | ||
</div> | ||
); | ||
}} | ||
/> | ||
); | ||
} | ||
|
||
function MyApp() { | ||
return ( | ||
<ProjectExtensionProviderForImageRegex> | ||
<MyComponent /> | ||
</ProjectExtensionProviderForImageRegex> | ||
); | ||
} |
28 changes: 28 additions & 0 deletions
28
...commercetools-frontend-application-shell-connectors/get-project-extension-image-regex.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { | ||
GetProjectExtensionImageRegex, | ||
ProjectExtensionProviderForImageRegex, | ||
} from '@commercetools-frontend/application-shell-connectors'; | ||
|
||
function MyComponent() { | ||
return ( | ||
<GetProjectExtensionImageRegex | ||
render={({ isLoading, imageRegex }) => { | ||
if (isLoading) return <LoadingSpinner />; | ||
|
||
return ( | ||
<div> | ||
<h1>Project images regex: {imageRegex}</h1> | ||
</div> | ||
); | ||
}} | ||
/> | ||
); | ||
} | ||
|
||
function MyApp() { | ||
return ( | ||
<ProjectExtensionProviderForImageRegex> | ||
<MyComponent /> | ||
</ProjectExtensionProviderForImageRegex> | ||
); | ||
} |
15 changes: 15 additions & 0 deletions
15
...-reference/commercetools-frontend-application-shell-connectors/use-application-context.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { useApplicationContext } from '@commercetools-frontend/application-shell-connectors'; | ||
|
||
const DisplayLocale = () => { | ||
const dataLocale = useApplicationContext( | ||
(applicationContext) => applicationContext.dataLocale | ||
); | ||
|
||
return ( | ||
<div> | ||
<h1>Current data locale: {dataLocale}</h1> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DisplayLocale; |
15 changes: 15 additions & 0 deletions
15
...reference/commercetools-frontend-application-shell-connectors/use-application-context.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { useApplicationContext } from '@commercetools-frontend/application-shell-connectors'; | ||
|
||
const DisplayLocale = () => { | ||
const dataLocale = useApplicationContext( | ||
(applicationContext) => applicationContext.dataLocale | ||
); | ||
|
||
return ( | ||
<div> | ||
<h1>Current data locale: {dataLocale}</h1> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DisplayLocale; |
16 changes: 16 additions & 0 deletions
16
...reference/commercetools-frontend-application-shell-connectors/with-application-context.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { withApplicationContext } from '@commercetools-frontend/application-shell-connectors'; | ||
import { Component } from 'react'; | ||
|
||
class DisplayLocale extends Component { | ||
render() { | ||
return ( | ||
<div> | ||
<h1>Current data locale: {this.props.dataLocale}</h1> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default withApplicationContext((applicationContext) => ({ | ||
dataLocale: applicationContext.dataLocale, | ||
}))(DisplayLocale); |
29 changes: 29 additions & 0 deletions
29
...eference/commercetools-frontend-application-shell-connectors/with-application-context.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { | ||
withApplicationContext, | ||
type TApplicationContext, | ||
} from '@commercetools-frontend/application-shell-connectors'; | ||
import { Component } from 'react'; | ||
|
||
type TOwnProps = { | ||
// ... | ||
}; | ||
|
||
type TMappedProps = { | ||
dataLocale: TApplicationContext<{}>['dataLocale']; | ||
}; | ||
|
||
class DisplayLocale extends Component<TOwnProps & TMappedProps> { | ||
render() { | ||
return ( | ||
<div> | ||
<h1>Current data locale: {this.props.dataLocale}</h1> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default withApplicationContext<TMappedProps, {}, {}>( | ||
(applicationContext) => ({ | ||
dataLocale: applicationContext.dataLocale, | ||
}) | ||
)(DisplayLocale); |
31 changes: 31 additions & 0 deletions
31
...commercetools-frontend-application-shell-connectors/with-project-extension-image-regex.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { | ||
withProjectExtensionImageRegex, | ||
ProjectExtensionProviderForImageRegex, | ||
} from '@commercetools-frontend/application-shell-connectors'; | ||
import { Component } from 'react'; | ||
|
||
class MyComponent extends Component { | ||
render() { | ||
const { imageRegexData } = this.props; | ||
return ( | ||
<div> | ||
<h2>Project images regex is loading?: {imageRegexData.isLoading}</h2> | ||
<h2> | ||
Project images regex: {JSON.stringify(imageRegexData.imageRegex)} | ||
</h2> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
const WrappedComponent = withProjectExtensionImageRegex()(MyComponent); | ||
|
||
class MyApp extends Component { | ||
render() { | ||
return ( | ||
<ProjectExtensionProviderForImageRegex> | ||
<WrappedComponent /> | ||
</ProjectExtensionProviderForImageRegex> | ||
); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...ommercetools-frontend-application-shell-connectors/with-project-extension-image-regex.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { | ||
withProjectExtensionImageRegex, | ||
ProjectExtensionProviderForImageRegex, | ||
} from '@commercetools-frontend/application-shell-connectors'; | ||
import type { TImageRegexContext } from '@commercetools-frontend/application-shell-connectors/dist/declarations/src/components/project-extension-image-regex/project-extension-image-regex'; | ||
import { Component } from 'react'; | ||
|
||
type TOwnProps = { | ||
// ... | ||
}; | ||
|
||
type TMappedProps = { | ||
imageRegexData?: TImageRegexContext; | ||
}; | ||
|
||
class MyComponent extends Component<TOwnProps & TMappedProps> { | ||
render() { | ||
const { imageRegexData } = this.props; | ||
return ( | ||
<div> | ||
<h2>Project images regex is loading?: {imageRegexData?.isLoading}</h2> | ||
<h2>Project images regex: {imageRegexData?.imageRegex}</h2> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
const WrappedComponent = withProjectExtensionImageRegex< | ||
TOwnProps & TMappedProps | ||
>()(MyComponent); | ||
|
||
export class MyApp extends Component { | ||
render() { | ||
return ( | ||
<ProjectExtensionProviderForImageRegex> | ||
<WrappedComponent /> | ||
</ProjectExtensionProviderForImageRegex> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters