-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New component library #1
Merged
jonathan-waarneming-nl
merged 80 commits into
develop
from
feature/new-component-library
Jul 25, 2023
Merged
Changes from all commits
Commits
Show all changes
80 commits
Select commit
Hold shift + click to select a range
40481ed
First component
jonathan-waarneming-nl ff2db9f
Add Accordion
jonathan-waarneming-nl f5883f3
Move unit tests
jonathan-waarneming-nl 30d5218
Add Icons
jonathan-waarneming-nl dc9a1c1
v0.0.17
jonathan-waarneming-nl 040338d
Add IconButton
jonathan-waarneming-nl 8ed952e
Add BackButton
jonathan-waarneming-nl f122010
Add BackgroundImage
jonathan-waarneming-nl 757da64
Add LargeButton
jonathan-waarneming-nl fc2cb9d
v0.0.18
jonathan-waarneming-nl 24b488b
Add linting
jonathan-waarneming-nl 4c21ab3
Add BottomSheet
jonathan-waarneming-nl a317f31
Change import/export strategy
jonathan-waarneming-nl b4081b7
Checkbox + Chip
jonathan-waarneming-nl 7483fb7
Add PageIndicator
jonathan-waarneming-nl 3335a18
v0.0.26
jonathan-waarneming-nl 59c6b75
v0.0.27
jonathan-waarneming-nl 268a872
Add Accordion and setup jest differently
jonathan-waarneming-nl 337a48a
Add ContentImage
jonathan-waarneming-nl 6969520
v0.0.28
jonathan-waarneming-nl 45e75e0
Add IconText
jonathan-waarneming-nl 814a409
Add Date
jonathan-waarneming-nl 9490c3f
Add Disclose
jonathan-waarneming-nl c78504c
Add FilterButton
jonathan-waarneming-nl 9a5345b
Add IconView
jonathan-waarneming-nl 94a9822
Add InputField
jonathan-waarneming-nl 076d24f
Close Location
jonathan-waarneming-nl de7874b
Add Message
jonathan-waarneming-nl be19620
Add MoreInfo
jonathan-waarneming-nl d50b61e
v0.0.29
jonathan-waarneming-nl 6ffce22
Add Notification
jonathan-waarneming-nl 93bf8e1
Add Popup
jonathan-waarneming-nl 6f13eeb
Add NotificationPopup
jonathan-waarneming-nl 1c1426a
Add Panel
jonathan-waarneming-nl f86e9f8
Add PhotoStrip
jonathan-waarneming-nl 30c5925
Add Pictogram
jonathan-waarneming-nl 2aa3b2e
Add ProgressBarList
jonathan-waarneming-nl 0459832
Add RenderHtmlWrapper
jonathan-waarneming-nl 99ea9ff
Add Tooltip
jonathan-waarneming-nl a5ee3f0
Add WebLink
jonathan-waarneming-nl 6ee4732
Set typescript properly
jonathan-waarneming-nl 7883d61
Initial files
jonathan-waarneming-nl 6b12bb9
Working components
jonathan-waarneming-nl 4294f39
Add interface for packing
jonathan-waarneming-nl d82bdb2
v0.0.30
jonathan-waarneming-nl 83602e3
Remove .DS_Store
jonathan-waarneming-nl 1aa5ec1
Update gitignore
jonathan-waarneming-nl 8d44f18
v0.0.31
jonathan-waarneming-nl c8e0512
v0.0.32
jonathan-waarneming-nl 6abe187
v0.0.33
jonathan-waarneming-nl 8b53f03
Use local translations
jonathan-waarneming-nl 4efd833
v0.0.34
jonathan-waarneming-nl 7993b4a
Remove react-native-reanimated
jonathan-waarneming-nl 8652228
v0.0.35
jonathan-waarneming-nl 8e2eba1
Rename to Translations + add Log
jonathan-waarneming-nl 1f06d9e
Remove unused file
jonathan-waarneming-nl 7dcbe3f
v0.0.36
jonathan-waarneming-nl 1264b13
v0.0.37
jonathan-waarneming-nl d00a2ba
Review comments
jonathan-waarneming-nl 96b248e
v0.0.38
jonathan-waarneming-nl 0513234
Use @observation.org/react-native-image-viewing
jonathan-waarneming-nl 4dfa325
Update README
jonathan-waarneming-nl 7a47458
Include Fontawesome pro key
jonathan-waarneming-nl 74fdc99
Use fontawesome in ci
jonathan-waarneming-nl 41bb512
Test
jonathan-waarneming-nl ffbaae4
Test
jonathan-waarneming-nl 57b917f
Add yarn
jonathan-waarneming-nl e9a0158
Small change
jonathan-waarneming-nl 4934cba
v0.0.39
jonathan-waarneming-nl 14cbb6d
Use repo instead of npm
jonathan-waarneming-nl 6271945
update yarn.lock
jonathan-waarneming-nl 27f0175
Update package.json
jonathan-waarneming-nl dca4df9
Ignore error
jonathan-waarneming-nl 5bf757c
Review comments
jonathan-waarneming-nl 537f992
Last minor changes
jonathan-waarneming-nl 41bf399
Add comment for `FontStyle`
jonathan-waarneming-nl 2c40c36
Remove translations
jonathan-waarneming-nl 636573a
Use master branch of react-naitve-image-viewing
jonathan-waarneming-nl 832d1dd
Review comments (2)
jonathan-waarneming-nl e2593c7
Update version to 1.0.0
jonathan-waarneming-nl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
module.exports = { | ||
root: true, | ||
parser: '@typescript-eslint/parser', | ||
extends: '@react-native-community', | ||
plugins: ['react', 'jsx-a11y', 'import', 'react-native', 'observation'], | ||
settings: { | ||
'import/resolver': { | ||
node: { | ||
paths: ['.'], | ||
extensions: ['.js', '.jsx', '.android.js', '.ios.js', '.native.js', '.ts', '.tsx'], | ||
}, | ||
}, | ||
}, | ||
rules: { | ||
'observation/no-function-without-logging': 'error', | ||
'no-shadow': 'off', | ||
'@typescript-eslint/no-shadow': ['error'], | ||
semi: ['error', 'never'], | ||
'react-native/no-unused-styles': 'error', | ||
'react-native/no-inline-styles': 'off', | ||
'no-console': 'warn', | ||
curly: ['error', 'multi-line'], | ||
'prefer-destructuring': ['error'], | ||
'import/order': [ | ||
'error', | ||
{ | ||
groups: ['builtin', 'external', 'internal', ['parent', 'sibling']], | ||
pathGroups: [ | ||
{ | ||
pattern: 'react+(|-native)', | ||
group: 'external', | ||
position: 'before', | ||
}, | ||
], | ||
pathGroupsExcludedImportTypes: ['react+(|-native)'], | ||
'newlines-between': 'always', | ||
alphabetize: { | ||
order: 'asc', | ||
caseInsensitive: true, | ||
}, | ||
}, | ||
], | ||
}, | ||
env: { | ||
jest: true, | ||
browser: true, | ||
}, | ||
overrides: [ | ||
{ | ||
files: ['*.ts', '*.tsx'], | ||
rules: { | ||
'no-undef': 'off', | ||
}, | ||
}, | ||
{ | ||
files: ['*test.ts', '*test.tsx'], | ||
rules: { | ||
'observation/no-function-without-logging': 'off', | ||
}, | ||
}, | ||
], | ||
} |
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,11 @@ | ||
name: CI | ||
on: [push] | ||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Authenticate with FontAwesome Pro | ||
run: echo "//npm.fontawesome.com/:_authToken=${{ secrets.FONTAWESOME_NPM_AUTH_TOKEN }}" >> .npmrc && cat .npmrc | ||
- name: Install modules | ||
run: yarn |
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 @@ | ||
node_modules | ||
/lib/ | ||
coverage | ||
yarn-error.log | ||
.DS_Store |
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 @@ | ||
@fortawesome:registry=https://npm.fontawesome.com/ |
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,26 @@ | ||
module.exports = { | ||
// React Native 0.64.2 settings: | ||
// bracketSpacing: false, | ||
// jsxBracketSameLine: true, | ||
// singleQuote: true, | ||
// trailingComma: 'all', | ||
// arrowParens: 'avoid', | ||
printWidth: 120, | ||
bracketSpacing: true, | ||
bracketSameLine: false, | ||
semi: false, | ||
singleQuote: true, | ||
trailingComma: 'all', | ||
|
||
overrides: [ | ||
{ | ||
files: '*.xml', | ||
options: { | ||
printWidth: 80, | ||
tabWidth: 4, | ||
bracketSameLine: true, | ||
xmlWhitespaceSensitivity: 'ignore', | ||
}, | ||
}, | ||
], | ||
} |
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,25 @@ | ||
declare module 'accordion-collapse-react-native' { | ||
import { TouchableOpacityProps } from 'react-native' | ||
|
||
type CollapseProps = { | ||
isExpanded: boolean | ||
disabled?: boolean | ||
onToggle: (isExpanded: boolean) => void | ||
handleLongPress?: () => void | ||
touchableOpacityProps?: TouchableOpacityProps | ||
children?: React.ReactNode | ||
} | ||
const Collapse = (_props: CollapseProps) => React.ReactNode | ||
|
||
type CollapseHeaderProps = { | ||
children?: React.ReactNode | ||
} | ||
const CollapseHeader = (_props: CollapseHeaderProps) => React.ReactNode | ||
|
||
type CollapseBodyProps = { | ||
children?: React.ReactNode | ||
} | ||
const CollapseBody = (_props: CollapseBodyProps) => React.ReactNode | ||
|
||
export { Collapse, CollapseHeader, CollapseBody } | ||
} |
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,47 @@ | ||
# react-native-components | ||
React Native component library | ||
React Native component library for components used by React Native applications of Observation.org. | ||
There are 2 kinds of components: | ||
UI components: | ||
- `Accordion` | ||
- `BackButton` | ||
- `BackgroundImage` | ||
- `BottomSheet` | ||
- `Checkbox` | ||
- `Chip` | ||
- `ContentImage` | ||
- `Date` | ||
- `Disclose` | ||
- `FilterButton` | ||
- `IconButton` | ||
- `IconName` | ||
- `IconText` | ||
- `IconView` | ||
- `Icons` | ||
- `InputField` | ||
- `LargeButton (+ LargeButtonProps)` | ||
- `Icon/Icons` | ||
- `Lightbox` | ||
- `Location` | ||
- `Message` | ||
- `MoreInfo` | ||
- `Notification` | ||
- `NotificationPopup (+ NotificationPopupStaticProps)` | ||
- `PageIndicator` | ||
- `Panel` | ||
- `PhotoStrip` | ||
- `Popup` | ||
- `ProgressBar` | ||
- `ProgressBarList` | ||
- `RenderHtmlWrapper` | ||
- `TextLink` | ||
- `Tooltip` | ||
- `TooltipProps` | ||
- `WebLink` | ||
|
||
non-UI components: | ||
- `Log.setLogConfiguration`: A function to change the logging of the component library | ||
- `openUrl`: Opens URLs | ||
- `useShowBlurView`: A safe way to set a blur on the background | ||
- `theme`: A default theme with color and margins | ||
- `font`: A set of font styles | ||
- `text`: A set of text styles |
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,3 @@ | ||
module.exports = { | ||
presets: ['module:metro-react-native-babel-preset'], | ||
} |
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,9 @@ | ||
const path = require('path') | ||
|
||
module.exports = { | ||
process(sourceText, sourcePath, options) { | ||
return { | ||
code: `module.exports = ${JSON.stringify(path.basename(sourcePath))};`, | ||
} | ||
}, | ||
} |
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,20 @@ | ||
module.exports = { | ||
preset: 'react-native', | ||
transformIgnorePatterns: [ | ||
'node_modules/(?!((jest-)?react-native|@react-native(-community)?|@observation.org/react-native-image-viewing|i18n-js|react-native-scalable-image)/)', | ||
], | ||
setupFiles: ['./jest.mocks.js'], | ||
collectCoverageFrom: ['**/src/**/*.{js,ts,tsx}'], | ||
transform: { | ||
'^.+\\.tsx?$': [ | ||
'ts-jest', | ||
{ | ||
diagnostics: { | ||
exclude: ['**/node_modules/**'] | ||
}, | ||
} | ||
], | ||
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': | ||
'<rootDir>/fileTransformer.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,30 @@ | ||
/* eslint-disable observation/no-function-without-logging */ | ||
import React from 'react' | ||
import { Image } from 'react-native' | ||
|
||
// Mock font awesome | ||
const Icon = 'Icon' | ||
const getIconType = (prefix) => { | ||
switch (prefix) { | ||
case 'fas': | ||
return 'solid' | ||
case 'fal': | ||
return 'light' | ||
default: | ||
throw new Error() | ||
} | ||
} | ||
jest.mock('@fortawesome/react-native-fontawesome', () => ({ | ||
FontAwesomeIcon: (faIcon) => ( | ||
<Icon | ||
testID={faIcon.testID} | ||
color={faIcon.color} | ||
name={faIcon.icon.iconName} | ||
size={faIcon.size} | ||
style={faIcon.style} | ||
type={getIconType(faIcon.icon.prefix)} | ||
/> | ||
), | ||
})) | ||
|
||
Image.getSizeWithHeaders = jest.fn(() => Promise.resolve({ width: 0, height: 0 })) |
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,64 @@ | ||
{ | ||
"name": "@observation.org/react-native-components", | ||
"version": "1.0.0", | ||
"main": "src/index.ts", | ||
"repository": "[email protected]:observation/react-native-components.git", | ||
"author": "Observation.org", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@react-native-community/eslint-config": "^3.2.0", | ||
"@testing-library/react-native": "^12.1.2", | ||
"@tsconfig/react-native": "^3.0.2", | ||
"@types/color": "^3.0.3", | ||
"@types/jest": "^29.5.2", | ||
"@types/react": "^18.2.14", | ||
"@types/react-native": "^0.72.2", | ||
"eslint": "^8.19.0", | ||
"eslint-config-prettier": "^8.8.0", | ||
"eslint-plugin-import": "^2.27.5", | ||
"eslint-plugin-jsx-a11y": "^6.7.1", | ||
"eslint-plugin-observation": "https://github.com/observation/eslint-rules.git", | ||
"eslint-plugin-react": "^7.32.2", | ||
"eslint-plugin-react-hooks": "^4.6.0", | ||
"eslint-plugin-react-native": "^4.0.0", | ||
"jest": "^29.5.0", | ||
"prettier": "^2.8.8", | ||
"react": "^18.2.0", | ||
"react-native": "^0.72.3", | ||
"react-test-renderer": "^18.2.0", | ||
"ts-jest": "^29.1.0", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^4.8.4" | ||
}, | ||
"react-native": "src/index.ts", | ||
"scripts": { | ||
"lint": "tsc --noEmit && eslint src", | ||
"test": "jest --silent", | ||
"verify": "$npm_execpath lint && $npm_execpath test" | ||
}, | ||
"files": [ | ||
"src" | ||
], | ||
"peerDependencies": { | ||
"react": ">=18.2.0", | ||
"react-native": ">=0.72.3" | ||
}, | ||
"dependencies": { | ||
"@fortawesome/fontawesome-svg-core": "^6.3.0", | ||
"@fortawesome/pro-light-svg-icons": "^6.3.0", | ||
"@fortawesome/pro-solid-svg-icons": "^6.3.0", | ||
"@fortawesome/react-native-fontawesome": "^0.3.0", | ||
"@observation.org/react-native-image-viewing": "https://github.com/observation/react-native-image-viewing", | ||
"@react-native-community/blur": "^4.2.0", | ||
"@react-navigation/native": "^6.0.8", | ||
"accordion-collapse-react-native": "^1.0.0", | ||
"color": "^4.2.3", | ||
"i18n-iso-countries": "^7.2.0", | ||
"i18n-js": "^4.0.2", | ||
"moment": "2.29.4", | ||
"react-native-localize": "^2.1.9", | ||
"react-native-logs": "^5.0.1", | ||
"react-native-render-html": "^6.3.4", | ||
"react-native-scalable-image": "^1.1.0" | ||
} | ||
} |
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,60 @@ | ||
import React, { useState } from 'react' | ||
import { View } from 'react-native' | ||
|
||
// @ts-ignore | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deze moest toegevoegd worden omdat het problemen gaf bij het runnen van |
||
import { Collapse, CollapseHeader, CollapseBody } from 'accordion-collapse-react-native' | ||
|
||
import Log from '../lib/Log' | ||
import { unsafeLayoutAnimation } from '../lib/Utils' | ||
|
||
type Item = { | ||
title: string | ||
} | ||
|
||
type Props<T extends Item> = { | ||
list: T[] | ||
header: (item: T, index: number, isActive: boolean) => void | ||
footer: (item: T, index: number, isActive: boolean) => void | ||
body: (item: T) => JSX.Element | ||
onOpen: (index: number) => void | ||
ListEmptyComponent?: () => JSX.Element | ||
} | ||
|
||
const Accordion = <T extends Item>({ list, header, footer, body, onOpen, ListEmptyComponent }: Props<T>) => { | ||
const [activeIndex, setActiveIndex] = useState<number | null>(null) | ||
|
||
const onToggle = (index: number, isExpanded: boolean) => { | ||
Log.debug('Accordion:onToggle', index, isExpanded) | ||
unsafeLayoutAnimation('Accordion:onToggle') | ||
if (isExpanded) { | ||
setActiveIndex(index) | ||
onOpen(index) | ||
} else if (activeIndex === index) { | ||
setActiveIndex(null) | ||
} | ||
} | ||
|
||
return ( | ||
<View> | ||
{list.length === 0 | ||
? ListEmptyComponent?.() | ||
: list.map((item, index: number) => ( | ||
<Collapse | ||
key={item.title} | ||
isExpanded={index === activeIndex} | ||
onToggle={(isExpanded: boolean) => onToggle(index, isExpanded)} | ||
> | ||
<CollapseHeader> | ||
<> | ||
{header(item, index, index === activeIndex)} | ||
{footer(item, index, index === activeIndex)} | ||
</> | ||
</CollapseHeader> | ||
<CollapseBody>{body(item)}</CollapseBody> | ||
</Collapse> | ||
))} | ||
</View> | ||
) | ||
} | ||
|
||
export default Accordion |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
De 4 plugins die wel worden gebruikt bij ObsIdentify, konden hier weg.