generated from 8iq/nodejs-hackathon-boilerplate-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(codegen): INFRA-316 update components in template
- Loading branch information
1 parent
4e50e1b
commit f849ef7
Showing
17 changed files
with
176 additions
and
38 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
packages/codegen/templates/app00/domains/common/components/AppFrameWrapper.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,30 @@ | ||
import { css, Global } from '@emotion/react' | ||
import React, { useEffect } from 'react' | ||
|
||
import bridge from '@open-condo/bridge' | ||
|
||
const BODY_RESIZE_STYLES = css` | ||
body { | ||
height: auto; | ||
} | ||
` | ||
|
||
export const AppFrameWrapper: React.FC = ({ children }) => { | ||
useEffect(() => { | ||
const observer = new ResizeObserver((entries) => { | ||
if (entries && entries.length) { | ||
bridge.send('CondoWebAppResizeWindow', { height: entries[0].target.clientHeight }) | ||
} | ||
}) | ||
observer.observe(document.body) | ||
|
||
return () => observer.unobserve(document.body) | ||
}, []) | ||
|
||
return ( | ||
<> | ||
<Global styles={BODY_RESIZE_STYLES}/> | ||
{children} | ||
</> | ||
) | ||
} |
51 changes: 51 additions & 0 deletions
51
packages/codegen/templates/app00/domains/common/components/Loader.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,51 @@ | ||
/** @jsx jsx */ | ||
import { css, jsx } from '@emotion/react' | ||
import styled from '@emotion/styled' | ||
import { Spin, SpinProps } from 'antd' | ||
import React from 'react' | ||
|
||
import { colors } from '@open-condo/ui/dist/colors' | ||
|
||
|
||
const DEFAULT_DELAY = 200 // milliseconds | ||
|
||
const FilledLoaderContainer = styled.section` | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100%; | ||
width: 100%; | ||
` | ||
|
||
interface ILoaderProps extends SpinProps { | ||
fill?: boolean | ||
} | ||
|
||
export const Loader: React.FC<ILoaderProps> = (props) => { | ||
const { fill, ...other } = props | ||
// We need this to recolor antd spinner. It's not easily configurable from theme | ||
const coloredSpinnerStyles = css` | ||
.ant-spin-dot-item { | ||
background-color: ${colors.green[5]}; | ||
} | ||
` | ||
|
||
if (fill) { | ||
return ( | ||
<FilledLoaderContainer css={coloredSpinnerStyles}> | ||
<Spin {...other} /> | ||
</FilledLoaderContainer> | ||
) | ||
} | ||
|
||
return ( | ||
<section css={coloredSpinnerStyles}> | ||
<Spin {...other}/> | ||
</section> | ||
) | ||
} | ||
|
||
Loader.defaultProps = { | ||
fill: false, | ||
delay: DEFAULT_DELAY, | ||
} |
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
3 changes: 0 additions & 3 deletions
3
packages/codegen/templates/app00/domains/common/components/containers/BaseLayout/index.ts
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
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
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
5 changes: 5 additions & 0 deletions
5
packages/codegen/templates/app00/domains/common/constants/style.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,5 @@ | ||
const MAX_CONTENT_WIDTH = 1600 | ||
|
||
module.exports = { | ||
MAX_CONTENT_WIDTH | ||
} |
32 changes: 32 additions & 0 deletions
32
packages/codegen/templates/app00/domains/common/hooks/useLaunchParams.ts
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,32 @@ | ||
import { useState, useEffect } from 'react' | ||
|
||
import type { ResultResponseData, ErrorResponseData } from '@open-condo/bridge' | ||
import bridge from '@open-condo/bridge' | ||
|
||
type IUseLaunchParams = { | ||
loading: boolean | ||
error: ErrorResponseData | null | ||
context: ResultResponseData<'CondoWebAppGetLaunchParams'> | Record<string, never> | ||
} | ||
export function useLaunchParams (): IUseLaunchParams { | ||
const [loading, setLoading] = useState(true) | ||
const [error, setError] = useState<IUseLaunchParams['error']>(null) | ||
const [context, setContext] = useState<IUseLaunchParams['context']>({}) | ||
|
||
useEffect(() => { | ||
bridge | ||
.send('CondoWebAppGetLaunchParams') | ||
.then(setContext) | ||
.catch((err) => { | ||
setContext({}) | ||
setError(err) | ||
}) | ||
.finally(() => setLoading(false)) | ||
}, []) | ||
|
||
return { | ||
loading, | ||
error, | ||
context, | ||
} | ||
} |
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,19 @@ | ||
import en from '@app/{{name}}/lang/en/en.json' | ||
import ru from '@app/{{name}}/lang/ru/ru.json' | ||
|
||
|
||
// NOTE: Combine all keys together | ||
const translations = [ | ||
en, ru, | ||
] | ||
|
||
export type MessagesKeysType = keyof typeof translations[number] | ||
|
||
// NOTE: Override global interface allows us to use autocomplete in intl | ||
declare global { | ||
namespace FormatjsIntl { | ||
interface Message { | ||
ids: MessagesKeysType | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,2 +1,9 @@ | ||
{ | ||
"common.errors.serverError": "Server error", | ||
"NoAccessToStorage": "There is no access to the first-party cookies due to Intelligent Tracking Prevention! This is necessary to start authorization flow. Please grant an access by pressing the following button.", | ||
"AskForAccessButton": "Grant access", | ||
"AskForOpenWindowButton": "Open new tab and grant access", | ||
"NoAbleToAskForStorageAccess": "According the browser security restrictions, you will have to grant access to data storage. Please press the following button. There will be a new tab with a form that be opened. Please follow the instructions.", | ||
"GrantButtonPressed": "OK, thanks! Now you may close this page and press same button at the previous one.", | ||
"BeAbleToAskForStorageAccess": "To be able to ask for access to browser storage, please press the following button." | ||
} |
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 |
---|---|---|
@@ -1,2 +1,9 @@ | ||
{ | ||
"common.errors.serverError": "Ошибка сервера", | ||
"NoAccessToStorage": "Нет доступа к хранилищу first-party cookies из-за Intelligent Tracking Prevention. Доступ необходим для продолжения процесса авторизации. Пожалуйста, предоставьте доступ с помощью нажатия на кнопку ниже.", | ||
"AskForAccessButton": "Дать доступ", | ||
"AskForOpenWindowButton": "Открыть новую вкладку и дать доступ", | ||
"NoAbleToAskForStorageAccess": "Из-за ограничений безопасности браузера необходимо дать доступ к хранилищу браузера. Для этого нажмите кнопку ниже. Будет открыта новая вкладка. Следуйте указанным в ней инструкциям.", | ||
"GrantButtonPressed": "Отлично, спасибо! Теперь вернитесь в миниап пропусков и нажмите кнопку \"Предоставление доступа\".", | ||
"BeAbleToAskForStorageAccess": "Чтобы браузер предложил сделать запрос на доступ к хранилищу, нажмите на кнопку." | ||
} |
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
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
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.