Skip to content
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

Add GitHub community files and Documentation #20

Merged
merged 3 commits into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: ra1028
66 changes: 66 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Bug Report
description: File a bug report
title: "[Bug]: "
labels: ["bug"]
body:
- type: checkboxes
attributes:
label: Checklist
options:
- label: This is not a bug caused by platform.
required: true
- label: Reviewed the README and documentation.
required: true
- label: Checked existing issues & PRs to ensure not duplicated.
required: true

- type: textarea
attributes:
label: What happened?
validations:
required: true

- type: textarea
id: expected-behavior
attributes:
label: Expected Behavior
validations:
required: true

- type: textarea
attributes:
label: Reproduction Steps
value: |
1.
2.
3.
validations:
required: true

- type: input
attributes:
label: Swift Version
validations:
required: true

- type: input
attributes:
label: Library Version
validations:
required: true

- type: dropdown
attributes:
label: Platform
multiple: true
options:
- iOS
- tvOS
- macOS
- watchOS

- type: textarea
attributes:
label: Scrrenshot/Video/Gif
placeholder: |
Drag and drop screenshot, video, or gif here if you have.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/documentation_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Documentation Request
description: Suggest a new doc/example or ask a question about an existing one
title: "[Doc Request]: "
labels: ["documentation"]
body:
- type: checkboxes
attributes:
label: Checklist
options:
- label: Reviewed the README and documentation.
required: true
- label: Confirmed that this is uncovered by existing docs or examples.
required: true
- label: Checked existing issues & PRs to ensure not duplicated.
required: true

- type: textarea
attributes:
label: Description
placeholder: Describe what the scenario you think is uncovered by the existing ones and why you think it should be covered.
validations:
required: true

- type: textarea
attributes:
label: Motivation & Context
placeholder: Feel free to describe any additional context, such as why you thought the scenario should be covered.
42 changes: 42 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Feature Request
description: Suggest a new idea of feature
title: "[Feat Request]: "
labels: ["enhancement"]
body:
- type: checkboxes
attributes:
label: Checklist
options:
- label: Reviewed the README and documentation.
required: true
- label: Checked existing issues & PRs to ensure not duplicated.
required: true

- type: textarea
attributes:
label: Description
placeholder: Describe the feature that you want to propose.
validations:
required: true

- type: textarea
attributes:
label: Example Use Case
placeholder: Describe an example use case that the feature is useful.
validations:
required: true

- type: textarea
attributes:
label: Alternative Solution
placeholder: Describe alternatives solutions that you've considered.

- type: textarea
attributes:
label: Proposed Solution
placeholder: Describe how we can achieve the feature you'd like to suggest.

- type: textarea
attributes:
label: Motivation & Context
placeholder: Feel free to describe any additional context, such as why you want to suggest this feature.
19 changes: 19 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Pull Request Type

- [ ] Bug fix
- [ ] New feature
- [ ] Refactoring
- [ ] Documentation update
- [ ] Chore

## Issue for this PR

Link:

## Description

## Motivation and Context

## Impact on Existing Code

## Screenshot/Video/Gif
28 changes: 28 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# https://github.com/actions/virtual-environments

name: docs

on:
release:
types: [published]
workflow_dispatch:

jobs:
test:
name: Test
runs-on: macos-12
strategy:
matrix:
xcode_version:
- 13.3
env:
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode_version }}.app
steps:
- uses: actions/checkout@v2
- name: Build docs
run: make docs
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ DerivedData
build/
archive/
*.xcframework

## SwiftPM
.swiftpm
.build
docs
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,24 @@ format:
lint:
$(TOOL) swift-format lint -s -p -r $(SWIFT_FILE_PATHS)

.PHONY: docs
docs:
$(PACKAGE) \
--allow-writing-to-directory docs \
generate-documentation \
--product Hooks \
--disable-indexing \
--transform-for-static-hosting \
--hosting-base-path swiftui-hooks \
--output-path docs

.PHONY: docs-preview
docs-preview:
$(PACKAGE) \
--disable-sandbox \
preview-documentation \
--product Hooks

.PHONY: test
test: test-library build-examples

Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<h1 align="center">SwiftUI Hooks</h1>
<p align="center">A SwiftUI implementation of <a href="https://reactjs.org/docs/hooks-intro.html">React Hooks</a>.</p>
<p align="center">Enhances reusability of stateful logic and gives state and lifecycle to function view.</p>
<p align="center"><a href="https://ra1028.github.io/SwiftUI-Hooks/documentation/hooks">📔 API Reference</a></p>
<p align="center">
<a href="https://github.com/ra1028/SwiftUI-Hooks/actions"><img alt="test" src="https://github.com/ra1028/SwiftUI-Hooks/workflows/test/badge.svg"></a>
<a href="https://github.com/ra1028/SwiftUI-Hooks/releases/latest"><img alt="release" src="https://img.shields.io/github/v/release/ra1028/SwiftUI-Hooks.svg"/></a>
Expand Down Expand Up @@ -100,6 +101,11 @@ And then, include "Hooks" as a dependency for your target:
]),
```

### Documentation

- [API Reference](https://ra1028.github.io/SwiftUI-Hooks/documentation/hooks)
- [Example apps](Examples)

---

## Hooks API
Expand Down
51 changes: 51 additions & 0 deletions Sources/Hooks/Hooks.docc/Hooks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# ``Hooks``

🪝 A SwiftUI implementation of React Hooks. Enhances reusability of stateful logic and gives state and lifecycle to function view.

## Overview

SwiftUI Hooks is a SwiftUI implementation of React Hooks. Brings the state and lifecycle into the function view, without depending on elements that are only allowed to be used in struct views such as @State or @ObservedObject.
It allows you to reuse stateful logic between views by building custom hooks composed with multiple hooks.
Furthermore, hooks such as useEffect also solve the problem of lack of lifecycles in SwiftUI.

## Source Code

<https://github.com/ra1028/SwiftUI-Hooks>

## Topics

### Hooks

- ``useState(_:)``
- ``useEffect(_:_:)``
- ``useLayoutEffect(_:_:)``
- ``useMemo(_:_:)``
- ``useRef(_:)``
- ``useReducer(_:initialState:)``
- ``useEnvironment(_:)``
- ``usePublisher(_:_:)``
- ``usePublisherSubscribe(_:)``
- ``useContext(_:)``

### User Interface

- ``HookScope``
- ``HookView``

### Values

- ``Context``
- ``AsyncPhase``
- ``RefObject``
- ``HookUpdateStrategy``

### Testing

- ``HookTester``

### Internal System

- ``useHook(_:)``
- ``Hook``
- ``HookCoordinator``
- ``HookDispatcher``
9 changes: 9 additions & 0 deletions Tools/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@
"version" : "1.1.2"
}
},
{
"identity" : "swift-docc-plugin",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-docc-plugin",
"state" : {
"revision" : "3303b164430d9a7055ba484c8ead67a52f7b74f6",
"version" : "1.0.0"
}
},
{
"identity" : "swift-format",
"kind" : "remoteSourceControl",
Expand Down
2 changes: 2 additions & 0 deletions Tools/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import PackageDescription
let package = Package(
name: "Tools",
dependencies: [
.package(name: "SwiftUI-Hooks", path: ".."),
.package(url: "https://github.com/apple/swift-docc-plugin", exact: "1.0.0"),
.package(url: "https://github.com/apple/swift-format.git", exact: "0.50600.0"),
.package(url: "https://github.com/yonaskolb/XcodeGen.git", exact: "2.28.0"),
]
Expand Down