generated from 8iq/nodejs-hackathon-boilerplate-starter-kit
-
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.
feat(condo) DOMA-7889 News cross posting frontend (#4830)
* fix(condo) DOMA-7889: init news sharing integration * feat(condo): DOMA-7888: proof of concept greendom integration app * feat(condo): DOMA-7889: proof of concept frontend code * feat(condo): DOMA-7889: remove telegram sharing submodule from the code feat(condo): DOMA-7889: fix gitmodules * fix(ui): DOMA-7889: make Card component grow with row && fix border on hover * refactor(condo): DOMA-7889: introduce translations on SelectSharingAppControl.tsx * refactor(condo): DOMA-7889: beautify news type markup * feat(condo): DOMA-7889: add app skipping feature and fix card grids * fix(condo): DOMA-7889: fix a few linter errors * feat(condo): DOMA-7889: drop skipped steps on sharing app update * refactor(condo): DOMA-7889: refactor settings page * refactor(condo): DOMA-7889: refactor preview widget * chore(condo): DOMA-7889: update submodules * refactor(condo): DOMA-7889: implement cleaner form architecture – store form data in useState by steps * refactor(condo): DOMA-7889: update migrations * fix(condo): DOMA-7889: fix typescript errors * fix(condo): DOMA-7889: add more useCallbacks fix(condo): DOMA-7889: add more useCallbacks * fix(condo): DOMA-7889: fix eslint errors * chore(condo): DOMA-7889: update submodule to relevant version * chore(condo): DOMA-7889: fix variable usage before declaration error * feat(condo): DOMA-7889: add publish delayed shared news item task, handle new sendAt logic, add tests * fix(condo): DOMA-7889: fix eslint errors and some warnings fix(condo): DOMA-7889: fix eslint errors and some warnings * fix(condo): DOMA-7889: upgrade tests fix(condo): DOMA-7889: upgrade tests * fix(condo): DOMA-7889: fix eslint errors fix(condo): DOMA-7889: fix eslint errors * fix(condo): DOMA-7889: remove greendom submodule fix(condo): DOMA-7889: remove greendom submodule * fix(condo): DOMA-7889: regenerate migrations * fix(condo): DOMA-7889: regenerate migrations * fix(ui): DOMA-7889: fix linter errors * fix(condo): DOMA-7889: fixes on self-review * fix(condo): DOMA-7889: fixes on self-review * fix(condo): DOMA-7889: fixes on self-review * fix(condo): DOMA-7889: fixes on self-review * chore(condo): DOMA-7889: update lockfile * chore(condo): DOMA-7889: update lockfile * chore(condo): DOMA-7889: fixes on self-review * chore(condo): DOMA-7889: fixes on self-review * chore(condo): DOMA-7889: fixes on self-review * refactor(condo): DOMA-7889: lower the amount of executed publishNewsItemSharing.js tasks * chore(condo): DOMA-7889: regenerate migrations * refactor(condo): DOMA-7888: implement fixes on review * refactor(condo): DOMA-7888: add feature flags based form resolver * refactor(condo): DOMA-7888: fixes on linter review * refactor(condo): DOMA-7888: fixes on linter review * refactor(condo): DOMA-7888: fixes on linter review * refactor(condo): DOMA-7888: fixes on linter review * refactor(condo): DOMA-7888: fixes on review * refactor(condo): DOMA-7888: fixes on review * refactor(condo): DOMA-7888: fixes on review * refactor(condo): DOMA-7888: fixes on review
- Loading branch information
1 parent
126b1f6
commit 3578c3d
Showing
41 changed files
with
3,485 additions
and
575 deletions.
There are no files selected for viewing
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
928 changes: 635 additions & 293 deletions
928
apps/condo/domains/news/components/NewsForm/BaseNewsForm.tsx
Large diffs are not rendered by default.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
apps/condo/domains/news/components/NewsForm/BaseNewsFormByFeatureFlag.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,33 @@ | ||
/** | ||
* Condo currently supports two UIs for news sharing: | ||
* 1. BaseNewsForm – ui with support of cross posting functionality | ||
* 2. OldBaseNewsForm - legacy ui without support of cross posting functionality | ||
* TODO (DOMA-9331) Remove this component and OldBaseNewsForm | ||
* | ||
* Note: OldBaseNewsForm was slightly modified to support new API of NewsPreview component, as well as few other minor changes | ||
*/ | ||
|
||
import React from 'react' | ||
|
||
import { useFeatureFlags } from '@open-condo/featureflags/FeatureFlagsContext' | ||
|
||
import { NEWS_SHARING } from '@condo/domains/common/constants/featureflags' | ||
import { BaseNewsFormProps, BaseNewsForm } from '@condo/domains/news/components/NewsForm/BaseNewsForm' | ||
import { OldBaseNewsForm } from '@condo/domains/news/components/NewsForm/OldBaseNewsForm' | ||
|
||
export const BaseNewsFormByFeatureFlag: React.FC<BaseNewsFormProps> = ( | ||
props | ||
) => { | ||
const { useFlag } = useFeatureFlags() | ||
const isNewsSharingEnabled = useFlag(NEWS_SHARING) | ||
|
||
if (isNewsSharingEnabled) { | ||
return <BaseNewsForm | ||
{...props} | ||
/> | ||
} else { | ||
return <OldBaseNewsForm | ||
{...props} | ||
/> | ||
} | ||
} |
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
52 changes: 52 additions & 0 deletions
52
apps/condo/domains/news/components/NewsForm/NewsCardGrid.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,52 @@ | ||
import { Row, Col } from 'antd' | ||
import React from 'react' | ||
|
||
import { useContainerSize } from '@open-condo/ui/dist/hooks' | ||
|
||
import type { RowProps } from 'antd' | ||
|
||
type NewsCardGridProps = { | ||
children: React.ReactNode | ||
minColWidth?: number | ||
gap?: number, | ||
minCols?: number, | ||
maxCols?: number | ||
} | ||
|
||
const GAP = 32 | ||
const ROW_GUTTER: RowProps['gutter'] = [GAP, GAP] | ||
const MIN_COL_WIDTH = 350 | ||
const MIN_COLS = 1 | ||
const MAX_COLS = 4 | ||
|
||
function getColsAmount ( | ||
width: number, | ||
minColWidth: number = MIN_COL_WIDTH, | ||
gap: number = GAP, | ||
minCols: number = MIN_COLS, | ||
maxCols: number = MAX_COLS, | ||
): number { | ||
const fitCols = Math.floor((width + gap) / (minColWidth + gap)) | ||
return Math.min(maxCols, Math.max(minCols, fitCols)) | ||
} | ||
|
||
export const NewsCardGrid: React.FC<NewsCardGridProps> = ({ | ||
children, | ||
minColWidth, | ||
gap, | ||
minCols, | ||
maxCols, | ||
}) => { | ||
const [{ width }, setRef] = useContainerSize() | ||
const cols = getColsAmount(width, minColWidth, gap, minCols, maxCols) | ||
const colSpan = 24 / cols | ||
return ( | ||
<Row gutter={ROW_GUTTER} ref={setRef}> | ||
{React.Children.map(children, (child, index) => ( | ||
<Col span={colSpan} key={index}> | ||
{child} | ||
</Col> | ||
))} | ||
</Row> | ||
) | ||
} |
Oops, something went wrong.