diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 40b878d..0000000 --- a/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -node_modules/ \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index f1e52bd..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1,122 +0,0 @@ -module.exports = { - root: true, - extends: [ - "eslint:recommended", - "plugin:react/recommended", - "plugin:@typescript-eslint/recommended", - "@react-native-community", - "prettier", - ], - ignorePatterns: [ - "**/*/*.js", - "*.js", - "*.svg", - "*.json", - "*.png", - "package.json", - "package-lock.json", - ], - parser: "@typescript-eslint/parser", - plugins: [ - "import", - "react", - "react-native", - "prettier", - "react-hooks", - "@typescript-eslint", - "promise", - "jest", - "unused-imports", - ], - env: { - browser: true, - es2021: true, - "jest/globals": true, - "react-native/react-native": true, - }, - settings: { - "import/resolver": { - node: { - extensions: [ - ".js", - ".jsx", - ".ts", - ".tsx", - ".d.ts", - ".android.js", - ".android.jsx", - ".android.ts", - ".android.tsx", - ".ios.js", - ".ios.jsx", - ".ios.ts", - ".ios.tsx", - ".web.js", - ".web.jsx", - ".web.ts", - ".web.tsx", - ], - }, - }, - }, - rules: { - quotes: [ - "error", - "double", - { - avoidEscape: true, - }, - ], - "import/extensions": [ - "error", - "never", - { - svg: "always", - model: "always", - style: "always", - png: "always", - jpg: "always", - json: "always", - constant: "always", - }, - ], - "react-hooks/exhaustive-deps": 0, - "max-len": ["error", 120], - "@typescript-eslint/ban-ts-comment": 2, - "@typescript-eslint/no-empty-function": 0, - "@typescript-eslint/no-explicit-any": 1, - "@typescript-eslint/explicit-module-boundary-types": 0, - "react/jsx-filename-extension": ["error", { extensions: [".tsx"] }], - "react-native/no-unused-styles": 2, - "react-native/split-platform-components": 2, - "react-native/no-inline-styles": 0, - "react-native/no-color-literals": 0, - "react-native/no-raw-text": 0, - "import/no-extraneous-dependencies": 2, - "import/no-named-as-default-member": 2, - "import/order": 0, - "import/no-duplicates": 2, - "import/no-useless-path-segments": 2, - "import/no-cycle": 2, - "import/prefer-default-export": 0, - "import/no-anonymous-default-export": 0, - "import/named": 0, - "@typescript-eslint/no-empty-interface": 0, - "import/namespace": 0, - "import/default": 0, - "import/no-named-as-default": 0, - "import/no-unused-modules": 0, - "import/no-deprecated": 0, - "@typescript-eslint/indent": 0, - "react-hooks/rules-of-hooks": 2, - camelcase: 2, - "prefer-destructuring": 2, - "no-nested-ternary": 2, - "prettier/prettier": [ - "error", - { - endOfLine: "auto", - }, - ], - }, -}; diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 631037d..ce130e7 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,6 +1,6 @@ # These are supported funding model platforms -github: [wrathchaos] +github: [kuraydev] patreon: # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username ko_fi: # Replace with a single Ko-fi username diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..abbfea5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,36 @@ +--- +name: Bug report +about: Report a problem with react-native-apple-card-views +title: "[Bug] " +labels: bug +assignees: "" +--- + +## Describe the bug + +A clear and concise description of what the bug is. + +## Reproduction + +Steps to reproduce, ideally an [Expo Snack](https://snack.expo.dev) or minimal repo: + +1. ... +2. ... + +## Expected behaviour + +What you expected to happen. + +## Environment + +- `react-native-apple-card-views` version: +- `@freakycoder/react-native-bounceable` version: +- React Native version: +- React version: +- Expo SDK (if applicable): +- Platform(s): iOS / Android +- New Architecture enabled: yes / no + +## Additional context + +Logs, screenshots, or anything else that helps. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..e20d271 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: Discussions / Questions + url: https://github.com/kuraydev/react-native-apple-card-views/discussions + about: Ask questions and discuss usage here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..f537228 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,23 @@ +--- +name: Feature request +about: Suggest an idea or improvement +title: "[Feature] " +labels: enhancement +assignees: "" +--- + +## Problem + +What problem would this feature solve? What are you trying to do? + +## Proposed solution + +A clear and concise description of what you want to happen. + +## Alternatives considered + +Any alternative solutions or features you've considered. + +## Additional context + +Mockups, references to the real Apple App Store UI, or anything else. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..b3cfba8 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,23 @@ +## Summary + + + +## Type of change + +- [ ] Bug fix (non-breaking change which fixes an issue) +- [ ] New feature (non-breaking change which adds functionality) +- [ ] Breaking change (fix or feature that changes existing behaviour or the public API) +- [ ] Documentation / tooling only + +## Checklist + +- [ ] `npm run lint` passes +- [ ] `npm run typecheck` passes +- [ ] `npm test` passes +- [ ] `npm run build` produces `build/dist` +- [ ] I did not rename public exports, prop names, or change runtime defaults (or this is documented as breaking above) +- [ ] Commits follow [Conventional Commits](https://www.conventionalcommits.org/) + +## Related issues + + diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..d958554 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,20 @@ +version: 2 +updates: + - package-ecosystem: npm + directory: "/" + schedule: + interval: weekly + open-pull-requests-limit: 10 + commit-message: + prefix: "build(deps)" + prefix-development: "build(deps-dev)" + groups: + dev-dependencies: + dependency-type: development + + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: weekly + commit-message: + prefix: "ci" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..56d4938 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,47 @@ +name: CI + +on: + push: + branches: [master, main] + pull_request: + branches: [master, main] + +permissions: + contents: read + +jobs: + verify: + name: Lint, typecheck, test & build (Node ${{ matrix.node }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + node: [18, 20, 22] + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node ${{ matrix.node }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node }} + + - name: Install dependencies + run: npm install --legacy-peer-deps + + - name: Lint + run: npm run lint + + - name: Typecheck + run: npm run typecheck + + - name: Test + run: npm test -- --ci --coverage + + - name: Build + run: npm run build + + - name: Verify build output + run: | + test -f build/dist/index.js + test -f build/dist/index.d.ts diff --git a/.gitignore b/.gitignore index a7acc97..0438ec9 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,6 @@ buck-out/ # Bundle artifact *.jsbundle + +# TypeScript incremental build info +*.tsbuildinfo diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..619afcd --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,43 @@ +# Changelog + +All notable changes to this project are documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Added + +- Exported the `IAppleCardProps` and `IAppOfTheDayCardProps` prop interfaces from the package entry. +- `accessibilityLabel` prop on both cards; pressable areas now expose `accessibilityRole="button"` and a `hitSlop`. +- `package.json` `types`, `module`, `react-native`, `source`, `exports`, and `files` fields. +- `peerDependencies` (`react`, `react-native`, `@freakycoder/react-native-bounceable`) with deliberately wide ranges, plus `peerDependenciesMeta`. +- Jest + `@testing-library/react-native` test suite covering render, prop wiring, press handlers, accessibility labels, and the responsive style factory. +- GitHub Actions CI (lint + typecheck + test + build across Node 18/20/22) and a restored Dependabot config. +- `CONTRIBUTING.md`, `CODE_OF_CONDUCT.md`, issue templates, and a pull request template. +- ESLint 9 flat config (`eslint.config.js`). + +### Changed + +- Both cards now read `useWindowDimensions()` so layout reacts to rotation / resize instead of capturing `Dimensions.get('window')` once at module load. +- Both cards are wrapped in `React.memo` and expose a `displayName`. +- Repointed repository / homepage / bugs / author / funding metadata from the legacy WrathChaos / freakycoder URLs to the `kuraydev` GitHub owner. +- Replaced the dead `tslint` lint script with ESLint, and migrated the legacy `.eslintrc.js` to a flat config. +- Migrated the build to a dedicated `tsconfig.build.json`; the published entry (`main`) and types remain at `build/dist`. +- Updated the Babel preset to `@react-native/babel-preset`. +- Rewrote the README props tables to match the code (the footnote prop is `footnote`, not `footnoteText`; removed the non-existent default values) and added TypeScript, New Architecture, and Expo notes. + +### Removed + +- Dead / deprecated devDependencies: `@types/react-native`, `react-native-typescript-transformer`, `prettier-format`, `npm-post-install`, `eslint-config-airbnb`, `@react-native-community/eslint-config`, `cpx`. +- Stale root `app.json` (a copy-paste from `react-native-header-view` that referenced non-existent assets). + +### Fixed + +- Stopped spreading `...rest` onto multiple elements; rest props are now routed to the single intended pressable. +- Tightened `AppOfTheDayCard.iconSource` from `any` to `ImageSourcePropType`. + +## [3.0.0] - 2023-02-04 + +- Initial baseline for this changelog. See the git history for prior releases. diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..12f87fd --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,46 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behaviour that contributes to a positive environment include: + +- Demonstrating empathy and kindness toward other people +- Being respectful of differing opinions, viewpoints, and experiences +- Giving and gracefully accepting constructive feedback +- Accepting responsibility and apologising to those affected by our mistakes +- Focusing on what is best for the overall community + +Examples of unacceptable behaviour include: + +- The use of sexualised language or imagery, and sexual attention or advances +- Trolling, insulting or derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information without explicit permission +- Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behaviour may be +reported to the project maintainer at **kurayogun@gmail.com**. All complaints +will be reviewed and investigated promptly and fairly. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. + +[homepage]: https://www.contributor-covenant.org diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..dd1bb2e --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,50 @@ +# Contributing + +Thanks for your interest in improving **react-native-apple-card-views**! ๐Ÿ + +## Getting started + +```bash +git clone https://github.com/kuraydev/react-native-apple-card-views.git +cd react-native-apple-card-views +npm install +``` + +## Development workflow + +The library source lives in [`lib/`](./lib). Useful scripts: + +| Script | Purpose | +| --- | --- | +| `npm run lint` | ESLint (flat config) over `lib/` | +| `npm run lint:fix` | ESLint with autofix | +| `npm run typecheck` | `tsc --noEmit` | +| `npm test` | Jest + `@testing-library/react-native` | +| `npm run build` | Emit `build/dist` (JS + `.d.ts`) via `tsconfig.build.json` | +| `npm run format` | Prettier over `lib/` | + +Please run `npm run lint && npm run typecheck && npm test && npm run build` +before opening a PR โ€” CI runs all four on Node 18, 20 and 22. + +## Backward compatibility + +This is a published, widely-used package. **Do not** rename public exports, +component prop names, or change runtime default behaviour without flagging the +change as breaking. Fix docs to match the code, not the other way around. + +## Commit messages + +We use [Conventional Commits](https://www.conventionalcommits.org/). Examples: + +- `fix: route rest props to a single pressable` +- `feat: add accessibilityLabel to AppleCard` +- `docs: correct the footnote prop name` + +## Pull requests + +1. Fork and create a feature branch. +2. Make your change with tests where it makes sense. +3. Ensure lint, typecheck, tests and build pass. +4. Open a PR using the template and describe any breaking change explicitly. + +By contributing you agree that your contributions are licensed under the MIT license. diff --git a/README.md b/README.md index 9055506..ead9b93 100755 --- a/README.md +++ b/README.md @@ -1,130 +1,184 @@ React Native Apple Card Views -[![Battle Tested โœ…](https://img.shields.io/badge/-Battle--Tested%20%E2%9C%85-03666e?style=for-the-badge)](https://github.com/WrathChaos/react-native-button) - -[![Fully customizable and perfect clone of Apple, App Store Card Views for React Native](https://img.shields.io/badge/-Fully%20customizable%20and%20perfect%20clone%20of%20Apple%2C%20App%20Store%20Card%20Views%20for%20React%20Native-orange?style=for-the-badge)](https://github.com/WrathChaos/react-native-apple-card-views) - +[![Battle Tested โœ…](https://img.shields.io/badge/-Battle--Tested%20%E2%9C%85-03666e?style=for-the-badge)](https://github.com/kuraydev/react-native-apple-card-views) [![npm version](https://img.shields.io/npm/v/react-native-apple-card-views.svg?style=for-the-badge)](https://www.npmjs.com/package/react-native-apple-card-views) -[![npm](https://img.shields.io/npm/dt/react-native-apple-card-views.svg?style=for-the-badge)](https://www.npmjs.org/package/react-native-apple-card-views) +[![npm downloads](https://img.shields.io/npm/dt/react-native-apple-card-views.svg?style=for-the-badge)](https://www.npmjs.com/package/react-native-apple-card-views) ![Platform - Android and iOS](https://img.shields.io/badge/platform-Android%20%7C%20iOS-blue.svg?style=for-the-badge) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?style=for-the-badge)](https://opensource.org/licenses/MIT) [![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg?style=for-the-badge)](https://github.com/prettier/prettier) +> Fully customizable, pixel-faithful clones of Apple's App Store card views for React Native โ€” written in TypeScript, ships with types, and works with both the New and the Old Architecture. +

- React Native Apple Card Views - React Native Apple Card Views + AppleCard + AppOfTheDayCard

- React Native Apple Card Views + React Native Apple Card Views demo

+## Features -Version 3 ๐Ÿฅณ ๐Ÿš€ -- Only one dependency is required ๐Ÿ๏ธ -- Other dependencies are removed/extracted -- Expo Compatible ๐ŸŽช -- Code cleaning ๐Ÿงน +- ๐Ÿ Two presentational components: `AppleCard` (game hero card) and `AppOfTheDayCard` +- ๐Ÿ๏ธ A single peer dependency (`@freakycoder/react-native-bounceable`) for the press bounce +- ๐ŸŽช Expo compatible โ€” pure JS/TS, no native modules to link +- ๐Ÿงฉ New Architecture (Fabric) ready โ€” only renders core RN primitives +- ๐Ÿ“ Responsive: the cards react to rotation / resize via `useWindowDimensions` +- โ™ฟ Accessible: pressable areas expose `accessibilityRole="button"` + labels +- ๐ŸŸฆ First-class TypeScript types shipped in the package -## Installation & Expo Compatible - -Add the dependency: +## Installation ```bash -npm i react-native-apple-card-views +npm install react-native-apple-card-views @freakycoder/react-native-bounceable +# or +yarn add react-native-apple-card-views @freakycoder/react-native-bounceable ``` -## Peer Dependencies +### Peer dependencies -##### IMPORTANT! You need install them +This library declares the following peer dependencies โ€” install them in your app +(`react` / `react-native` are already present in every RN project): -```json -"@freakycoder/react-native-bounceable": ">= 1.0.3" -``` +| Peer dependency | Supported range | +| --- | --- | +| `react` | `>=17.0.0` | +| `react-native` | `>=0.64.0` | +| `@freakycoder/react-native-bounceable` | `>=1.0.0` | -# Options +> No native linking / pod install step is required โ€” the package is pure JavaScript/TypeScript. -- [AppleCard](https://github.com/WrathChaos/react-native-apple-card-views#applecard-usage) -- [AppOfTheDayCard](https://github.com/WrathChaos/react-native-apple-card-views#appofthedaycard-usage) +## Compatibility -# Usage +| Topic | Status | +| --- | --- | +| New Architecture (Fabric / TurboModules) | โœ… Compatible โ€” renders only `View` / `Text` / `Image` / `ImageBackground`, no native module | +| Old Architecture (Paper) | โœ… Compatible | +| Expo (managed + bare) | โœ… Compatible โ€” no custom native code | +| TypeScript | โœ… Types bundled (`build/dist/index.d.ts`) | -## AppleCard Usage +## Usage -```jsx +```tsx +import {AppleCard, AppOfTheDayCard} from 'react-native-apple-card-views'; +``` + +### `AppleCard` + +```tsx {}} - smallTitle={"NEW GAME"} - largeTitle={"The Brilliance of Brawl Starts"} - footnote={ - "The next game from the markers of Clash Royale is here. Tap to learn more." - } /> ``` -## AppOfTheDayCard Usage +### `AppOfTheDayCard` -```jsx +```tsx {}} onButtonPress={() => {}} /> ``` -### Configuration - Props - -#### AppleCard Props - -| Property | Type | Default | Description | -| ------------------- | :------: | :------------------------------------------------------------------------: | ------------------------------------- | -| source | image | default image | set the image background | -| style | style | default | change the style of the card | -| smallTitle | string | NEW GAME | change the small title | -| largeTitle | string | The Brilliance of Brawl Stars | change the main large title | -| footnoteText | string | The next game from the markers of Clash Royale is here. Tap to learn more. | change the footnote text | -| backgroundStyle | style | default | set custom style for background image | -| smallTitleTextStyle | style | default | set custom style for small title | -| largeTitleTextStyle | style | default | set custom style for large title | -| footnoteTextStyle | style | default | set custom style for footnote | -| onPress | function | null | use this to set onPress functionality | - -#### AppOfTheDayCard Props - -| Property | Type | Default | Description | -| ------------------- | :------: | :-------------------------------: | ------------------------------------------------- | -| style | style | default | change the style of the card and image background | -| shadowStyle | style | default | change the style of the card's shadow | -| backgroundSource | image | default image | set the image background for main card | -| iconSource | image | default image | set the logo image | -| largeTitle | string | "APP OF THE DAY" | change the main large title | -| title | string | "Colorfy: Coloring Art Games" | change the title text | -| subtitle | string | "Drawing & painting for everyone" | change the subtitle text | -| buttonText | string | "GET" | change the button's text | -| buttonSubtitle | string | "In-App Purchases" | change the button's bottom subtitle | -| largeTitleTextStyle | style | default | set the custom style for large title | -| subtitleTextStyle | style | default | set the custom style for subtitle text | -| titleTextStyle | style | default | set the custom style for title text | -| iconStyle | style | default | set the custom style for icon | -| buttonOnPress | function | null | set a function for button's onPress | -| onPress | function | null | set a function for main card's onPress | - -## Roadmap - -- [x] ~~`AppleCard` Rewritten and Code Cleaning~~ -- [x] ~~`AppleCard` More Customization Options~~ +### TypeScript + +The prop interfaces are exported for convenience: + +```tsx +import type { + IAppleCardProps, + IAppOfTheDayCardProps, +} from 'react-native-apple-card-views'; +``` + +## Props + +> โš ๏ธ There are **no default prop values** โ€” the props listed as _required_ below +> must be supplied. (Previous READMEs documented defaults that did not exist.) + +### `AppleCard` + +| Prop | Type | Required | Description | +| --- | --- | :---: | --- | +| `source` | `ImageSourcePropType` | โœ… | Background image for the card | +| `smallTitle` | `string` | โœ… | Small eyebrow title above the large title | +| `largeTitle` | `string` | โœ… | Main large title | +| `footnote` | `string` | โœ… | Footnote text at the bottom of the card | +| `onPress` | `() => void` | โœ… | Called when the card is pressed | +| `style` | `StyleProp` | โ€” | Style applied to the pressable wrapper | +| `shadowStyle` | `StyleProp` | โ€” | Style for the outer shadow container | +| `backgroundStyle` | `StyleProp` | โ€” | Style for the background image | +| `smallTitleTextStyle` | `StyleProp` | โ€” | Style for the small title text | +| `largeTitleTextStyle` | `StyleProp` | โ€” | Style for the large title text | +| `footnoteTextStyle` | `StyleProp` | โ€” | Style for the footnote text | +| `accessibilityLabel` | `string` | โ€” | Overrides the default a11y label (`largeTitle`) | + +> **Note:** the footnote prop is named **`footnote`** (older docs incorrectly called it `footnoteText`). + +### `AppOfTheDayCard` + +| Prop | Type | Required | Description | +| --- | --- | :---: | --- | +| `title` | `string` | โœ… | App title text | +| `subtitle` | `string` | โœ… | App subtitle text | +| `largeTitle` | `string` | โœ… | Main large title (use `\n` for line breaks) | +| `buttonText` | `string` | โœ… | Text inside the GET button | +| `buttonSubtitle` | `string` | โœ… | Subtitle under the button (e.g. "In-App Purchases") | +| `iconSource` | `ImageSourcePropType` | โœ… | App icon image | +| `backgroundSource` | `ImageSourcePropType` | โœ… | Background image for the card | +| `onPress` | `() => void` | โœ… | Called when the card is pressed | +| `onButtonPress` | `() => void` | โœ… | Called when the GET button is pressed | +| `style` | `StyleProp` | โ€” | Style applied to the card container | +| `shadowStyle` | `StyleProp` | โ€” | Style for the outer shadow container | +| `iconStyle` | `StyleProp` | โ€” | Style for the app icon | +| `titleTextStyle` | `StyleProp` | โ€” | Style for the title text | +| `subtitleTextStyle` | `StyleProp` | โ€” | Style for the subtitle text | +| `largeTitleTextStyle` | `StyleProp` | โ€” | Style for the large title text | +| `buttonSubtitleTextStyle` | `StyleProp` | โ€” | Style for the button subtitle text | +| `gradientColors` | `string[]` | โ€” | **Reserved / no-op.** Accepted for forward compatibility; does not currently render a gradient | +| `accessibilityLabel` | `string` | โ€” | Overrides the default a11y label (`title`) | + +## Running the example apps + +Two example apps live in this repo: + +- [`example/`](./example) โ€” bare React Native +- [`example-expo/`](./example-expo) โ€” Expo + +```bash +cd example # or example-expo +yarn install +yarn ios # or: yarn android / yarn start +``` + +## Contributing + +Contributions are welcome! Please read [CONTRIBUTING.md](./CONTRIBUTING.md) and the +[Code of Conduct](./CODE_OF_CONDUCT.md) before opening a PR. Commit messages follow +[Conventional Commits](https://www.conventionalcommits.org/). + +## Changelog + +See [CHANGELOG.md](./CHANGELOG.md) for a history of notable changes. ## Author -FreakyCoder, kurayogun@gmail.com +Kuray (FreakyCoder) โ€” kurayogun@gmail.com +GitHub: [@kuraydev](https://github.com/kuraydev) ## License -React Native Apple Card Views Library is available under the MIT license. See the LICENSE file for more info. +React Native Apple Card Views is available under the MIT license. See the +[LICENSE](./LICENSE) file for more info. diff --git a/__mocks__/@freakycoder/react-native-bounceable.js b/__mocks__/@freakycoder/react-native-bounceable.js new file mode 100644 index 0000000..e53a307 --- /dev/null +++ b/__mocks__/@freakycoder/react-native-bounceable.js @@ -0,0 +1,28 @@ +/** + * Deterministic test double for @freakycoder/react-native-bounceable. + * + * The real component animates a scale bounce on press; for unit tests we only + * care that it forwards `onPress`, accessibility props and children, so we map + * it onto a plain Pressable and drop the bounce-only props. + */ +const React = require('react'); +const {Pressable} = require('react-native'); + +const RNBounceable = React.forwardRef(function RNBounceable(props, ref) { + const { + bounceEffectIn, + bounceEffectOut, + bounceVelocityIn, + bounceVelocityOut, + bouncinessIn, + bouncinessOut, + children, + ...rest + } = props; + return React.createElement(Pressable, {ref, ...rest}, children); +}); + +RNBounceable.displayName = 'RNBounceable'; + +module.exports = RNBounceable; +module.exports.default = RNBounceable; diff --git a/app.json b/app.json deleted file mode 100755 index 86add37..0000000 --- a/app.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "expo": { - "name": "react-native-header-view", - "description": "Fully customizable Header View for React Native.", - "slug": "react-native-header-view", - "privacy": "public", - "sdkVersion": "31.0.0", - "platforms": ["ios", "android"], - "version": "1.0.0", - "orientation": "portrait", - "icon": "./assets/icon.png", - "splash": { - "image": "./assets/splash.png", - "resizeMode": "contain", - "backgroundColor": "#ffffff" - }, - "updates": { - "fallbackToCacheTimeout": 0 - }, - "assetBundlePatterns": ["**/*"], - "ios": { - "supportsTablet": true - } - } -} diff --git a/babel.config.js b/babel.config.js index cef1356..f7b3da3 100755 --- a/babel.config.js +++ b/babel.config.js @@ -1,5 +1,3 @@ module.exports = { - presets: [ - 'module:metro-react-native-babel-preset', - ], + presets: ['module:@react-native/babel-preset'], }; diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..8c0aca5 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,66 @@ +const js = require('@eslint/js'); +const tseslint = require('typescript-eslint'); +const react = require('eslint-plugin-react'); +const reactHooks = require('eslint-plugin-react-hooks'); +const prettier = require('eslint-config-prettier'); + +module.exports = tseslint.config( + { + ignores: [ + 'build/**', + 'node_modules/**', + 'example/**', + 'example-expo/**', + 'coverage/**', + '**/*.js', + ], + }, + js.configs.recommended, + ...tseslint.configs.recommended, + { + files: ['lib/**/*.{ts,tsx}'], + plugins: { + react, + 'react-hooks': reactHooks, + }, + languageOptions: { + ecmaVersion: 2021, + sourceType: 'module', + parserOptions: { + ecmaFeatures: {jsx: true}, + }, + }, + settings: { + react: {version: 'detect'}, + }, + rules: { + ...react.configs.recommended.rules, + ...reactHooks.configs.recommended.rules, + 'react/react-in-jsx-scope': 'off', + 'react/prop-types': 'off', + '@typescript-eslint/no-explicit-any': 'warn', + '@typescript-eslint/no-unused-vars': [ + 'error', + {argsIgnorePattern: '^_', varsIgnorePattern: '^_'}, + ], + '@typescript-eslint/no-empty-function': 'off', + }, + }, + { + files: ['lib/**/__tests__/**/*.{ts,tsx}'], + languageOptions: { + globals: { + jest: 'readonly', + describe: 'readonly', + it: 'readonly', + test: 'readonly', + expect: 'readonly', + beforeEach: 'readonly', + afterEach: 'readonly', + beforeAll: 'readonly', + afterAll: 'readonly', + }, + }, + }, + prettier, +); diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 0000000..0a16e5b --- /dev/null +++ b/jest.config.js @@ -0,0 +1,14 @@ +module.exports = { + preset: 'react-native', + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], + setupFilesAfterEnv: ['@testing-library/react-native/extend-expect'], + testMatch: ['/lib/**/__tests__/**/*.test.{ts,tsx}'], + collectCoverageFrom: [ + 'lib/**/*.{ts,tsx}', + '!lib/**/*.style.ts', + '!lib/**/__tests__/**', + ], + transformIgnorePatterns: [ + 'node_modules/(?!(jest-)?@react-native|react-native|@react-native-community|@freakycoder/react-native-bounceable)', + ], +}; diff --git a/lib/__tests__/index.test.tsx b/lib/__tests__/index.test.tsx new file mode 100644 index 0000000..c77f528 --- /dev/null +++ b/lib/__tests__/index.test.tsx @@ -0,0 +1,14 @@ +import * as Lib from '../index'; + +describe('package entry (barrel)', () => { + it('exports AppleCard and AppOfTheDayCard as named exports', () => { + expect(Lib.AppleCard).toBeDefined(); + expect(Lib.AppOfTheDayCard).toBeDefined(); + }); + + it('does not regress the public export surface', () => { + expect(Object.keys(Lib).sort()).toEqual( + ['AppOfTheDayCard', 'AppleCard'].sort(), + ); + }); +}); diff --git a/lib/components/AppOfTheDayCard/AppOfTheDayCard.style.ts b/lib/components/AppOfTheDayCard/AppOfTheDayCard.style.ts index 692eac0..36101f3 100644 --- a/lib/components/AppOfTheDayCard/AppOfTheDayCard.style.ts +++ b/lib/components/AppOfTheDayCard/AppOfTheDayCard.style.ts @@ -1,11 +1,4 @@ -import { - ViewStyle, - TextStyle, - ImageStyle, - StyleSheet, - Dimensions, -} from 'react-native'; -const {width: ScreenWidth, height: ScreenHeight} = Dimensions.get('window'); +import {ViewStyle, TextStyle, ImageStyle, StyleSheet} from 'react-native'; interface Style { container: ViewStyle; @@ -23,94 +16,101 @@ interface Style { buttonInnerContainer: ViewStyle; buttonSubtitleTextStyle: TextStyle; } -export default StyleSheet.create