reflex-react-github-calendar 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- reflex_react_github_calendar-0.1.0/LICENSE +179 -0
- reflex_react_github_calendar-0.1.0/PKG-INFO +216 -0
- reflex_react_github_calendar-0.1.0/README.md +189 -0
- reflex_react_github_calendar-0.1.0/custom_components/reflex_react_github_calendar/__init__.py +41 -0
- reflex_react_github_calendar-0.1.0/custom_components/reflex_react_github_calendar/domain.py +47 -0
- reflex_react_github_calendar-0.1.0/custom_components/reflex_react_github_calendar/github_calendar.py +170 -0
- reflex_react_github_calendar-0.1.0/custom_components/reflex_react_github_calendar/github_calendar.pyi +82 -0
- reflex_react_github_calendar-0.1.0/custom_components/reflex_react_github_calendar/recipes.py +78 -0
- reflex_react_github_calendar-0.1.0/custom_components/reflex_react_github_calendar.egg-info/PKG-INFO +216 -0
- reflex_react_github_calendar-0.1.0/custom_components/reflex_react_github_calendar.egg-info/SOURCES.txt +19 -0
- reflex_react_github_calendar-0.1.0/custom_components/reflex_react_github_calendar.egg-info/dependency_links.txt +1 -0
- reflex_react_github_calendar-0.1.0/custom_components/reflex_react_github_calendar.egg-info/requires.txt +6 -0
- reflex_react_github_calendar-0.1.0/custom_components/reflex_react_github_calendar.egg-info/top_level.txt +1 -0
- reflex_react_github_calendar-0.1.0/pyproject.toml +44 -0
- reflex_react_github_calendar-0.1.0/setup.cfg +4 -0
- reflex_react_github_calendar-0.1.0/tests/test_contract.py +73 -0
- reflex_react_github_calendar-0.1.0/tests/test_domain.py +44 -0
- reflex_react_github_calendar-0.1.0/tests/test_github_calendar.py +53 -0
- reflex_react_github_calendar-0.1.0/tests/test_public_api.py +20 -0
- reflex_react_github_calendar-0.1.0/tests/test_recipes.py +79 -0
- reflex_react_github_calendar-0.1.0/tests/test_tooltip_styles.py +34 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
95
|
+
Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works.
|
|
111
|
+
|
|
112
|
+
You may add Your own copyright statement to Your modifications and
|
|
113
|
+
may provide additional or different license terms and conditions
|
|
114
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
115
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
116
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
117
|
+
the conditions stated in this License.
|
|
118
|
+
|
|
119
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
120
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
121
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
122
|
+
this License, without any additional terms or conditions.
|
|
123
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
124
|
+
the terms of any separate license agreement you may have executed
|
|
125
|
+
with Licensor regarding such Contributions.
|
|
126
|
+
|
|
127
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
128
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
129
|
+
except as required for reasonable and customary use in describing the
|
|
130
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
131
|
+
|
|
132
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
133
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
134
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
135
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
136
|
+
implied, including, without limitation, any warranties or conditions
|
|
137
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
138
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
139
|
+
appropriateness of using or redistributing the Work and assume any
|
|
140
|
+
risks associated with Your exercise of permissions under this License.
|
|
141
|
+
|
|
142
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
143
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
144
|
+
unless required by applicable law (such as deliberate and grossly
|
|
145
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
146
|
+
liable to You for damages, including any direct, indirect, special,
|
|
147
|
+
incidental, or consequential damages of any character arising as a
|
|
148
|
+
result of this License or out of the use or inability to use the
|
|
149
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
150
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
151
|
+
other commercial damages or losses), even if such Contributor
|
|
152
|
+
has been advised of the possibility of such damages.
|
|
153
|
+
|
|
154
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
155
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
156
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
157
|
+
or other liability obligations and/or rights consistent with this
|
|
158
|
+
License. However, in accepting such obligations, You may act only
|
|
159
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
160
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
161
|
+
defend, and hold each Contributor harmless for any liability
|
|
162
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
163
|
+
of your accepting any such warranty or additional liability.
|
|
164
|
+
|
|
165
|
+
END OF TERMS AND CONDITIONS
|
|
166
|
+
|
|
167
|
+
Copyright 2026 Ernesto Crespo
|
|
168
|
+
|
|
169
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
170
|
+
you may not use this file except in compliance with the License.
|
|
171
|
+
You may obtain a copy of the License at
|
|
172
|
+
|
|
173
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
174
|
+
|
|
175
|
+
Unless required by applicable law or agreed to in writing, software
|
|
176
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
177
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
178
|
+
See the License for the specific language governing permissions and
|
|
179
|
+
limitations under the License.
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: reflex-react-github-calendar
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Reflex custom component wrapping react-github-calendar v5 (a GitHub contributions heatmap with themes, sizing, labels and localization).
|
|
5
|
+
Author-email: Ernesto Crespo <ecrespo@gmail.com>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/ecrespo/reflex-react-github-calendar
|
|
8
|
+
Project-URL: Repository, https://github.com/ecrespo/reflex-react-github-calendar
|
|
9
|
+
Project-URL: Issues, https://github.com/ecrespo/reflex-react-github-calendar/issues
|
|
10
|
+
Project-URL: react-github-calendar, https://github.com/grubersjoe/react-github-calendar
|
|
11
|
+
Keywords: reflex,reflex-custom-components,react-github-calendar,github,calendar,heatmap,contributions,component
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Framework :: AsyncIO
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Requires-Dist: reflex>=0.8.0
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: build; extra == "dev"
|
|
24
|
+
Requires-Dist: twine; extra == "dev"
|
|
25
|
+
Requires-Dist: pytest; extra == "dev"
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
# reflex-react-github-calendar
|
|
29
|
+
|
|
30
|
+
A [Reflex](https://reflex.dev) custom component that wraps
|
|
31
|
+
[`react-github-calendar`](https://github.com/grubersjoe/react-github-calendar)
|
|
32
|
+
v5 — a GitHub-style contributions heatmap — so you can drop it into a pure-Python
|
|
33
|
+
Reflex app in one line.
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
import reflex as rx
|
|
37
|
+
from reflex_react_github_calendar import github_calendar
|
|
38
|
+
|
|
39
|
+
def index() -> rx.Component:
|
|
40
|
+
return github_calendar(username="grubersjoe")
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
> **Status:** Core wrapper + Phase 3 helpers implemented (TDD/DDD) and packaged
|
|
44
|
+
> as a publish-ready Reflex custom component (type stub generated, `twine check`
|
|
45
|
+
> passing). The wrapper, demo app, full SDD docs, CI scaffold, the DDD `Theme`
|
|
46
|
+
> value object and the advanced function-prop recipes are in place. See
|
|
47
|
+
> [`docs/sdd/04-plan.md`](docs/sdd/04-plan.md) for the roadmap and current phase.
|
|
48
|
+
|
|
49
|
+
## Features
|
|
50
|
+
|
|
51
|
+
- One-line GitHub contributions calendar for any username.
|
|
52
|
+
- Full prop parity with `react-github-calendar` v5 **and** its underlying
|
|
53
|
+
`react-activity-calendar`: sizing, color scheme, custom themes, month/weekday
|
|
54
|
+
labels, color legend, total count, activity levels, week start, localization,
|
|
55
|
+
year selection, and a loading state.
|
|
56
|
+
- Handles the tricky parts for you: ESM-only package, **named** export, and the
|
|
57
|
+
client-side data fetch (rendered as a no-SSR component).
|
|
58
|
+
- A demo app with one interactive section per feature.
|
|
59
|
+
|
|
60
|
+
## Installation
|
|
61
|
+
|
|
62
|
+
```shell
|
|
63
|
+
# From PyPI (after the first release):
|
|
64
|
+
pip install reflex-react-github-calendar
|
|
65
|
+
|
|
66
|
+
# From source (development):
|
|
67
|
+
git clone https://github.com/ecrespo/reflex-react-github-calendar
|
|
68
|
+
cd reflex-react-github-calendar
|
|
69
|
+
pip install -e ".[dev]"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Reflex installs the underlying npm package (`react-github-calendar@5.0.6`) into
|
|
73
|
+
your app's frontend automatically on first run.
|
|
74
|
+
|
|
75
|
+
## Usage
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
import reflex as rx
|
|
79
|
+
from reflex_react_github_calendar import github_calendar
|
|
80
|
+
|
|
81
|
+
class State(rx.State):
|
|
82
|
+
username: str = "grubersjoe"
|
|
83
|
+
|
|
84
|
+
def index() -> rx.Component:
|
|
85
|
+
return github_calendar(
|
|
86
|
+
username=State.username,
|
|
87
|
+
year=2024,
|
|
88
|
+
block_size=14,
|
|
89
|
+
color_scheme="dark",
|
|
90
|
+
show_weekday_labels=["mon", "wed", "fri"],
|
|
91
|
+
labels={"totalCount": "{{count}} contributions in {{year}}"},
|
|
92
|
+
theme={"light": ["#eee", "firebrick"], "dark": ["#333", "#d610ae"]},
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
app = rx.App()
|
|
96
|
+
app.add_page(index)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
See the full prop reference in
|
|
100
|
+
[`docs/sdd/03-component-spec.md`](docs/sdd/03-component-spec.md).
|
|
101
|
+
|
|
102
|
+
### Advanced helpers (no JavaScript required)
|
|
103
|
+
|
|
104
|
+
The advanced props (`transform_data`, `tooltips`, `render_block`) take JS
|
|
105
|
+
functions. Pure-Python helpers build them for you:
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
from reflex_react_github_calendar import (
|
|
109
|
+
github_calendar, Theme, last_half_year, activity_tooltip, link_blocks,
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
github_calendar(
|
|
113
|
+
username="grubersjoe",
|
|
114
|
+
theme=Theme(light=["#eee", "firebrick"]).to_prop(), # validated value object
|
|
115
|
+
transform_data=last_half_year(), # last 6 months only
|
|
116
|
+
tooltips=activity_tooltip("{{count}} contributions on {{date}}"),
|
|
117
|
+
render_block=link_blocks("https://github.com/grubersjoe?tab=overview"),
|
|
118
|
+
include_tooltip_styles=True, # opt-in headless CSS
|
|
119
|
+
)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
`Theme` validates the color scale at construction (2 or 5 colors) so
|
|
123
|
+
misconfiguration fails fast in Python instead of silently breaking in the
|
|
124
|
+
browser. See [`docs/sdd/03-component-spec.md`](docs/sdd/03-component-spec.md) §6.
|
|
125
|
+
|
|
126
|
+
## Running the demo
|
|
127
|
+
|
|
128
|
+
```shell
|
|
129
|
+
uv venv && uv pip install -e ".[dev]"
|
|
130
|
+
cd reflex_react_github_calendar_demo
|
|
131
|
+
uv run reflex init # first time only
|
|
132
|
+
uv run reflex run
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Open http://localhost:3000. The demo reproduces every upstream example: a basic
|
|
136
|
+
calendar with a username switcher, sizing controls, color scheme + custom
|
|
137
|
+
themes, label/legend toggles, a year selector, custom localization, and the
|
|
138
|
+
loading state.
|
|
139
|
+
|
|
140
|
+
## How it works
|
|
141
|
+
|
|
142
|
+
`react-github-calendar` fetches a user's contribution data in the browser from
|
|
143
|
+
`github-contributions-api.jogruber.de` and renders an SVG heatmap. This wrapper
|
|
144
|
+
maps its React surface to a Reflex component:
|
|
145
|
+
|
|
146
|
+
- subclasses `NoSSRComponent` (the data fetch is client-side),
|
|
147
|
+
- uses the v5 **named** export (`is_default = False`),
|
|
148
|
+
- pins the npm version for reproducible builds, and
|
|
149
|
+
- exposes every prop in idiomatic Python snake_case.
|
|
150
|
+
|
|
151
|
+
Full design rationale is in
|
|
152
|
+
[`docs/sdd/02-architecture.md`](docs/sdd/02-architecture.md).
|
|
153
|
+
|
|
154
|
+
## Documentation
|
|
155
|
+
|
|
156
|
+
Spec-Driven Design artifacts live in [`docs/sdd/`](docs/sdd):
|
|
157
|
+
|
|
158
|
+
| Doc | Purpose |
|
|
159
|
+
| --- | ------- |
|
|
160
|
+
| [`00-overview.md`](docs/sdd/00-overview.md) | Project framing & phase plan |
|
|
161
|
+
| [`01-prd.md`](docs/sdd/01-prd.md) | Product requirements |
|
|
162
|
+
| [`02-architecture.md`](docs/sdd/02-architecture.md) | Technical design & ADRs |
|
|
163
|
+
| [`03-component-spec.md`](docs/sdd/03-component-spec.md) | The API contract |
|
|
164
|
+
| [`04-plan.md`](docs/sdd/04-plan.md) | Implementation plan |
|
|
165
|
+
| [`05-tasks.md`](docs/sdd/05-tasks.md) | Task breakdown |
|
|
166
|
+
|
|
167
|
+
Research notes are in [`docs/research/`](docs/research).
|
|
168
|
+
|
|
169
|
+
## Development
|
|
170
|
+
|
|
171
|
+
This project uses [uv](https://docs.astral.sh/uv/) as its package manager.
|
|
172
|
+
|
|
173
|
+
```shell
|
|
174
|
+
uv venv # create .venv
|
|
175
|
+
uv pip install -e ".[dev]" # editable install + dev tools (build, twine, pytest)
|
|
176
|
+
uv run pytest # run the test suite
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
CI runs the test suite on Python 3.10–3.12 and builds the distribution on every
|
|
180
|
+
push (see [`.github/workflows/ci.yml`](.github/workflows/ci.yml)).
|
|
181
|
+
|
|
182
|
+
## Publishing (Reflex custom component)
|
|
183
|
+
|
|
184
|
+
This package follows the
|
|
185
|
+
[Reflex custom-component](https://reflex.dev/docs/custom-components/overview/)
|
|
186
|
+
conventions, so it is publishable to PyPI and discoverable in the Reflex gallery
|
|
187
|
+
(`reflex-custom-components` keyword).
|
|
188
|
+
|
|
189
|
+
**Prerequisites** (see the
|
|
190
|
+
[publishing prerequisites](https://reflex.dev/docs/custom-components/prerequisites-for-publishing/)):
|
|
191
|
+
a [PyPI](https://pypi.org) account and an API token.
|
|
192
|
+
|
|
193
|
+
**Build** — generates the `.pyi` type stub and the wheel + sdist in `dist/`:
|
|
194
|
+
|
|
195
|
+
```shell
|
|
196
|
+
uv run reflex component build
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
**Publish** — Reflex defers the upload to your tool of choice; with uv:
|
|
200
|
+
|
|
201
|
+
```shell
|
|
202
|
+
uv publish --token pypi-<your-token> # uploads dist/* to PyPI
|
|
203
|
+
# or, equivalently: uv run twine upload dist/*
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Then bump `version` in `pyproject.toml` and `__init__.py` for the next release,
|
|
207
|
+
and optionally run `uv run reflex component share` to submit gallery details.
|
|
208
|
+
|
|
209
|
+
## Credits & license
|
|
210
|
+
|
|
211
|
+
This package wraps [`react-github-calendar`](https://github.com/grubersjoe/react-github-calendar)
|
|
212
|
+
and [`react-activity-calendar`](https://github.com/grubersjoe/react-activity-calendar)
|
|
213
|
+
by Jonathan Gruber. Those libraries retain their own (MIT) licenses.
|
|
214
|
+
|
|
215
|
+
`reflex-react-github-calendar` is licensed under the
|
|
216
|
+
[Apache License 2.0](LICENSE).
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# reflex-react-github-calendar
|
|
2
|
+
|
|
3
|
+
A [Reflex](https://reflex.dev) custom component that wraps
|
|
4
|
+
[`react-github-calendar`](https://github.com/grubersjoe/react-github-calendar)
|
|
5
|
+
v5 — a GitHub-style contributions heatmap — so you can drop it into a pure-Python
|
|
6
|
+
Reflex app in one line.
|
|
7
|
+
|
|
8
|
+
```python
|
|
9
|
+
import reflex as rx
|
|
10
|
+
from reflex_react_github_calendar import github_calendar
|
|
11
|
+
|
|
12
|
+
def index() -> rx.Component:
|
|
13
|
+
return github_calendar(username="grubersjoe")
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
> **Status:** Core wrapper + Phase 3 helpers implemented (TDD/DDD) and packaged
|
|
17
|
+
> as a publish-ready Reflex custom component (type stub generated, `twine check`
|
|
18
|
+
> passing). The wrapper, demo app, full SDD docs, CI scaffold, the DDD `Theme`
|
|
19
|
+
> value object and the advanced function-prop recipes are in place. See
|
|
20
|
+
> [`docs/sdd/04-plan.md`](docs/sdd/04-plan.md) for the roadmap and current phase.
|
|
21
|
+
|
|
22
|
+
## Features
|
|
23
|
+
|
|
24
|
+
- One-line GitHub contributions calendar for any username.
|
|
25
|
+
- Full prop parity with `react-github-calendar` v5 **and** its underlying
|
|
26
|
+
`react-activity-calendar`: sizing, color scheme, custom themes, month/weekday
|
|
27
|
+
labels, color legend, total count, activity levels, week start, localization,
|
|
28
|
+
year selection, and a loading state.
|
|
29
|
+
- Handles the tricky parts for you: ESM-only package, **named** export, and the
|
|
30
|
+
client-side data fetch (rendered as a no-SSR component).
|
|
31
|
+
- A demo app with one interactive section per feature.
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
```shell
|
|
36
|
+
# From PyPI (after the first release):
|
|
37
|
+
pip install reflex-react-github-calendar
|
|
38
|
+
|
|
39
|
+
# From source (development):
|
|
40
|
+
git clone https://github.com/ecrespo/reflex-react-github-calendar
|
|
41
|
+
cd reflex-react-github-calendar
|
|
42
|
+
pip install -e ".[dev]"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Reflex installs the underlying npm package (`react-github-calendar@5.0.6`) into
|
|
46
|
+
your app's frontend automatically on first run.
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
import reflex as rx
|
|
52
|
+
from reflex_react_github_calendar import github_calendar
|
|
53
|
+
|
|
54
|
+
class State(rx.State):
|
|
55
|
+
username: str = "grubersjoe"
|
|
56
|
+
|
|
57
|
+
def index() -> rx.Component:
|
|
58
|
+
return github_calendar(
|
|
59
|
+
username=State.username,
|
|
60
|
+
year=2024,
|
|
61
|
+
block_size=14,
|
|
62
|
+
color_scheme="dark",
|
|
63
|
+
show_weekday_labels=["mon", "wed", "fri"],
|
|
64
|
+
labels={"totalCount": "{{count}} contributions in {{year}}"},
|
|
65
|
+
theme={"light": ["#eee", "firebrick"], "dark": ["#333", "#d610ae"]},
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
app = rx.App()
|
|
69
|
+
app.add_page(index)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
See the full prop reference in
|
|
73
|
+
[`docs/sdd/03-component-spec.md`](docs/sdd/03-component-spec.md).
|
|
74
|
+
|
|
75
|
+
### Advanced helpers (no JavaScript required)
|
|
76
|
+
|
|
77
|
+
The advanced props (`transform_data`, `tooltips`, `render_block`) take JS
|
|
78
|
+
functions. Pure-Python helpers build them for you:
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
from reflex_react_github_calendar import (
|
|
82
|
+
github_calendar, Theme, last_half_year, activity_tooltip, link_blocks,
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
github_calendar(
|
|
86
|
+
username="grubersjoe",
|
|
87
|
+
theme=Theme(light=["#eee", "firebrick"]).to_prop(), # validated value object
|
|
88
|
+
transform_data=last_half_year(), # last 6 months only
|
|
89
|
+
tooltips=activity_tooltip("{{count}} contributions on {{date}}"),
|
|
90
|
+
render_block=link_blocks("https://github.com/grubersjoe?tab=overview"),
|
|
91
|
+
include_tooltip_styles=True, # opt-in headless CSS
|
|
92
|
+
)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
`Theme` validates the color scale at construction (2 or 5 colors) so
|
|
96
|
+
misconfiguration fails fast in Python instead of silently breaking in the
|
|
97
|
+
browser. See [`docs/sdd/03-component-spec.md`](docs/sdd/03-component-spec.md) §6.
|
|
98
|
+
|
|
99
|
+
## Running the demo
|
|
100
|
+
|
|
101
|
+
```shell
|
|
102
|
+
uv venv && uv pip install -e ".[dev]"
|
|
103
|
+
cd reflex_react_github_calendar_demo
|
|
104
|
+
uv run reflex init # first time only
|
|
105
|
+
uv run reflex run
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Open http://localhost:3000. The demo reproduces every upstream example: a basic
|
|
109
|
+
calendar with a username switcher, sizing controls, color scheme + custom
|
|
110
|
+
themes, label/legend toggles, a year selector, custom localization, and the
|
|
111
|
+
loading state.
|
|
112
|
+
|
|
113
|
+
## How it works
|
|
114
|
+
|
|
115
|
+
`react-github-calendar` fetches a user's contribution data in the browser from
|
|
116
|
+
`github-contributions-api.jogruber.de` and renders an SVG heatmap. This wrapper
|
|
117
|
+
maps its React surface to a Reflex component:
|
|
118
|
+
|
|
119
|
+
- subclasses `NoSSRComponent` (the data fetch is client-side),
|
|
120
|
+
- uses the v5 **named** export (`is_default = False`),
|
|
121
|
+
- pins the npm version for reproducible builds, and
|
|
122
|
+
- exposes every prop in idiomatic Python snake_case.
|
|
123
|
+
|
|
124
|
+
Full design rationale is in
|
|
125
|
+
[`docs/sdd/02-architecture.md`](docs/sdd/02-architecture.md).
|
|
126
|
+
|
|
127
|
+
## Documentation
|
|
128
|
+
|
|
129
|
+
Spec-Driven Design artifacts live in [`docs/sdd/`](docs/sdd):
|
|
130
|
+
|
|
131
|
+
| Doc | Purpose |
|
|
132
|
+
| --- | ------- |
|
|
133
|
+
| [`00-overview.md`](docs/sdd/00-overview.md) | Project framing & phase plan |
|
|
134
|
+
| [`01-prd.md`](docs/sdd/01-prd.md) | Product requirements |
|
|
135
|
+
| [`02-architecture.md`](docs/sdd/02-architecture.md) | Technical design & ADRs |
|
|
136
|
+
| [`03-component-spec.md`](docs/sdd/03-component-spec.md) | The API contract |
|
|
137
|
+
| [`04-plan.md`](docs/sdd/04-plan.md) | Implementation plan |
|
|
138
|
+
| [`05-tasks.md`](docs/sdd/05-tasks.md) | Task breakdown |
|
|
139
|
+
|
|
140
|
+
Research notes are in [`docs/research/`](docs/research).
|
|
141
|
+
|
|
142
|
+
## Development
|
|
143
|
+
|
|
144
|
+
This project uses [uv](https://docs.astral.sh/uv/) as its package manager.
|
|
145
|
+
|
|
146
|
+
```shell
|
|
147
|
+
uv venv # create .venv
|
|
148
|
+
uv pip install -e ".[dev]" # editable install + dev tools (build, twine, pytest)
|
|
149
|
+
uv run pytest # run the test suite
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
CI runs the test suite on Python 3.10–3.12 and builds the distribution on every
|
|
153
|
+
push (see [`.github/workflows/ci.yml`](.github/workflows/ci.yml)).
|
|
154
|
+
|
|
155
|
+
## Publishing (Reflex custom component)
|
|
156
|
+
|
|
157
|
+
This package follows the
|
|
158
|
+
[Reflex custom-component](https://reflex.dev/docs/custom-components/overview/)
|
|
159
|
+
conventions, so it is publishable to PyPI and discoverable in the Reflex gallery
|
|
160
|
+
(`reflex-custom-components` keyword).
|
|
161
|
+
|
|
162
|
+
**Prerequisites** (see the
|
|
163
|
+
[publishing prerequisites](https://reflex.dev/docs/custom-components/prerequisites-for-publishing/)):
|
|
164
|
+
a [PyPI](https://pypi.org) account and an API token.
|
|
165
|
+
|
|
166
|
+
**Build** — generates the `.pyi` type stub and the wheel + sdist in `dist/`:
|
|
167
|
+
|
|
168
|
+
```shell
|
|
169
|
+
uv run reflex component build
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**Publish** — Reflex defers the upload to your tool of choice; with uv:
|
|
173
|
+
|
|
174
|
+
```shell
|
|
175
|
+
uv publish --token pypi-<your-token> # uploads dist/* to PyPI
|
|
176
|
+
# or, equivalently: uv run twine upload dist/*
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Then bump `version` in `pyproject.toml` and `__init__.py` for the next release,
|
|
180
|
+
and optionally run `uv run reflex component share` to submit gallery details.
|
|
181
|
+
|
|
182
|
+
## Credits & license
|
|
183
|
+
|
|
184
|
+
This package wraps [`react-github-calendar`](https://github.com/grubersjoe/react-github-calendar)
|
|
185
|
+
and [`react-activity-calendar`](https://github.com/grubersjoe/react-activity-calendar)
|
|
186
|
+
by Jonathan Gruber. Those libraries retain their own (MIT) licenses.
|
|
187
|
+
|
|
188
|
+
`reflex-react-github-calendar` is licensed under the
|
|
189
|
+
[Apache License 2.0](LICENSE).
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""reflex-react-github-calendar: a Reflex wrapper for react-github-calendar v5.
|
|
2
|
+
|
|
3
|
+
Public API::
|
|
4
|
+
|
|
5
|
+
from reflex_react_github_calendar import github_calendar, GitHubCalendar
|
|
6
|
+
|
|
7
|
+
# DDD value object for custom themes:
|
|
8
|
+
from reflex_react_github_calendar import Theme
|
|
9
|
+
|
|
10
|
+
# Phase 3 helpers for the advanced, function-valued props:
|
|
11
|
+
from reflex_react_github_calendar import (
|
|
12
|
+
last_n_days, last_half_year, activity_tooltip, link_blocks,
|
|
13
|
+
)
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from .domain import Theme
|
|
17
|
+
from .github_calendar import (
|
|
18
|
+
REACT_GITHUB_CALENDAR_VERSION,
|
|
19
|
+
GitHubCalendar,
|
|
20
|
+
github_calendar,
|
|
21
|
+
)
|
|
22
|
+
from .recipes import (
|
|
23
|
+
activity_tooltip,
|
|
24
|
+
last_half_year,
|
|
25
|
+
last_n_days,
|
|
26
|
+
link_blocks,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
__version__ = "0.1.0"
|
|
30
|
+
|
|
31
|
+
__all__ = [
|
|
32
|
+
"GitHubCalendar",
|
|
33
|
+
"github_calendar",
|
|
34
|
+
"REACT_GITHUB_CALENDAR_VERSION",
|
|
35
|
+
"Theme",
|
|
36
|
+
"last_n_days",
|
|
37
|
+
"last_half_year",
|
|
38
|
+
"activity_tooltip",
|
|
39
|
+
"link_blocks",
|
|
40
|
+
"__version__",
|
|
41
|
+
]
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""Domain value objects for the calendar (DDD).
|
|
2
|
+
|
|
3
|
+
These are framework-agnostic, immutable value objects that capture the upstream
|
|
4
|
+
invariants in Python so misconfiguration fails fast with a clear message,
|
|
5
|
+
instead of silently rendering a broken calendar in the browser.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from dataclasses import dataclass
|
|
11
|
+
|
|
12
|
+
# react-activity-calendar accepts either a two-color ``[zero, max]`` scale
|
|
13
|
+
# (the intermediate levels are interpolated) or one explicit color per level
|
|
14
|
+
# (``max_level + 1`` colors; react-github-calendar forces ``max_level = 4``).
|
|
15
|
+
_VALID_SCALE_LENGTHS = (2, 5)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _validate_scale(name: str, colors: list[str]) -> None:
|
|
19
|
+
if len(colors) not in _VALID_SCALE_LENGTHS:
|
|
20
|
+
raise ValueError(
|
|
21
|
+
f"theme '{name}' scale must have 2 or 5 colors, got {len(colors)}"
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@dataclass(frozen=True)
|
|
26
|
+
class Theme:
|
|
27
|
+
"""A custom calendar color theme.
|
|
28
|
+
|
|
29
|
+
``light`` is required; ``dark`` is optional (the library falls back to the
|
|
30
|
+
light scale when it is omitted). Each scale is either ``[zero, max]`` or
|
|
31
|
+
five explicit per-level colors.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
light: list[str]
|
|
35
|
+
dark: list[str] | None = None
|
|
36
|
+
|
|
37
|
+
def __post_init__(self) -> None:
|
|
38
|
+
_validate_scale("light", self.light)
|
|
39
|
+
if self.dark is not None:
|
|
40
|
+
_validate_scale("dark", self.dark)
|
|
41
|
+
|
|
42
|
+
def to_prop(self) -> dict[str, list[str]]:
|
|
43
|
+
"""Render the value object as the plain ``theme`` prop dict."""
|
|
44
|
+
prop: dict[str, list[str]] = {"light": list(self.light)}
|
|
45
|
+
if self.dark is not None:
|
|
46
|
+
prop["dark"] = list(self.dark)
|
|
47
|
+
return prop
|