reflex-react-github-calendar 0.1.0__py3-none-any.whl

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.
@@ -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
@@ -0,0 +1,170 @@
1
+ """A Reflex wrapper around react-github-calendar v5.
2
+
3
+ `react-github-calendar` (https://github.com/grubersjoe/react-github-calendar)
4
+ renders a GitHub-style contributions heatmap. It fetches the contribution data
5
+ for a username client-side from `github-contributions-api.jogruber.de` and draws
6
+ the calendar with the underlying `react-activity-calendar` component, so every
7
+ `react-activity-calendar` prop is supported here as well.
8
+
9
+ Public API::
10
+
11
+ from reflex_react_github_calendar import github_calendar
12
+
13
+ github_calendar(username="grubersjoe")
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ from typing import Any, Union
19
+
20
+ import reflex as rx
21
+ from reflex.components.component import NoSSRComponent
22
+
23
+ # Pinned npm version for reproducible builds (see ADR-6). Bump deliberately.
24
+ REACT_GITHUB_CALENDAR_VERSION = "react-github-calendar@5.0.6"
25
+
26
+
27
+ class GitHubCalendar(NoSSRComponent):
28
+ """A GitHub contributions calendar (heatmap) for a given username.
29
+
30
+ The component is client-side only: it fetches contribution data in the
31
+ browser, so it is wrapped as a ``NoSSRComponent`` (Reflex emits a dynamic,
32
+ SSR-disabled import). See ``docs/sdd/02-architecture.md`` for details.
33
+ """
34
+
35
+ # The npm package. v5 is a pure-ESM package with a *named* export.
36
+ library = REACT_GITHUB_CALENDAR_VERSION
37
+
38
+ # Named export `GitHubCalendar` (v5 removed the default export).
39
+ tag = "GitHubCalendar"
40
+ is_default = False
41
+
42
+ # ------------------------------------------------------------------ #
43
+ # react-github-calendar specific props
44
+ # ------------------------------------------------------------------ #
45
+
46
+ # GitHub username whose contributions are displayed (required).
47
+ username: rx.Var[str]
48
+
49
+ # Year to display: an integer (e.g. 2024) or the literal string "last"
50
+ # (the default — the trailing 12 months, matching GitHub's behaviour).
51
+ year: rx.Var[Union[int, str]]
52
+
53
+ # Message shown if fetching contribution data fails (when not throwing).
54
+ error_message: rx.Var[str] # -> errorMessage
55
+
56
+ # Raise instead of rendering ``error_message`` so a React error boundary
57
+ # can catch it.
58
+ throw_on_error: rx.Var[bool] # -> throwOnError
59
+
60
+ # ------------------------------------------------------------------ #
61
+ # react-activity-calendar props (all supported via composition)
62
+ # ------------------------------------------------------------------ #
63
+
64
+ # Margin between day blocks, in pixels (default 4).
65
+ block_margin: rx.Var[int] # -> blockMargin
66
+
67
+ # Corner radius of day blocks, in pixels (default 2).
68
+ block_radius: rx.Var[int] # -> blockRadius
69
+
70
+ # Size of each day block, in pixels (default 12).
71
+ block_size: rx.Var[int] # -> blockSize
72
+
73
+ # Force a color scheme instead of using the system one.
74
+ color_scheme: rx.Var[str] # "light" | "dark" -> colorScheme
75
+
76
+ # Base font size for labels, in pixels (default 14).
77
+ font_size: rx.Var[int] # -> fontSize
78
+
79
+ # Localization strings. ``totalCount`` supports the ``{{count}}`` and
80
+ # ``{{year}}`` placeholders, e.g.
81
+ # ``{"totalCount": "{{count}} contributions in {{year}}"}``.
82
+ labels: rx.Var[dict[str, Any]]
83
+
84
+ # Maximum activity level (default 4). react-github-calendar forces 4.
85
+ max_level: rx.Var[int] # -> maxLevel
86
+
87
+ # Minimum activity level (default 0).
88
+ min_level: rx.Var[int] # -> minLevel
89
+
90
+ # Show the loading placeholder; ``data`` is ignored while true.
91
+ loading: rx.Var[bool]
92
+
93
+ # Toggle the color legend below the calendar (default True).
94
+ show_color_legend: rx.Var[bool] # -> showColorLegend
95
+
96
+ # Toggle the month labels above the calendar (default True).
97
+ show_month_labels: rx.Var[bool] # -> showMonthLabels
98
+
99
+ # Toggle the total-count line below the calendar (default True).
100
+ show_total_count: rx.Var[bool] # -> showTotalCount
101
+
102
+ # Show weekday labels. Either a boolean, or a list of ISO weekday names
103
+ # to display selectively, e.g. ``["mon", "wed", "fri"]``.
104
+ show_weekday_labels: rx.Var[Union[bool, list[str]]] # -> showWeekdayLabels
105
+
106
+ # Custom color theme. Provide explicit per-level colors or a [min, max]
107
+ # pair per scheme, e.g.
108
+ # ``{"light": ["#eee", "firebrick"], "dark": ["#333", "#d610ae"]}``.
109
+ theme: rx.Var[dict[str, Any]]
110
+
111
+ # Index of the day used as the week start (0 = Sunday).
112
+ week_start: rx.Var[int] # -> weekStart
113
+
114
+ # ------------------------------------------------------------------ #
115
+ # Advanced / callback props
116
+ # ------------------------------------------------------------------ #
117
+ # The following props accept JavaScript functions on the React side and
118
+ # therefore must be passed as raw function ``Var``s (see
119
+ # docs/sdd/03-component-spec.md). They are declared here so they are
120
+ # forward-compatible; ergonomic Python helpers are tracked in Phase 3.
121
+
122
+ # Transform the fetched contribution list before rendering.
123
+ # ``(data: Activity[]) => Activity[]``
124
+ transform_data: rx.Var[Any] # -> transformData
125
+
126
+ # Render prop for day blocks (attach links / handlers / custom tooltips).
127
+ # ``(block: ReactElement, activity: Activity) => ReactElement``
128
+ render_block: rx.Var[Any] # -> renderBlock
129
+
130
+ # Render prop for color-legend blocks.
131
+ render_color_legend: rx.Var[Any] # -> renderColorLegend
132
+
133
+ # Tooltip configuration. ``activity.text`` / ``colorLegend.text`` are
134
+ # functions, so this generally needs a function-bearing ``Var``.
135
+ tooltips: rx.Var[dict[str, Any]]
136
+
137
+ # Reflex auto-converts snake_case prop names to camelCase, which covers
138
+ # every prop above. Add entries here only for names that need an explicit
139
+ # hint that the heuristic would get wrong.
140
+ _rename_props: dict[str, str] = {}
141
+
142
+ @classmethod
143
+ def create(cls, *children, include_tooltip_styles: bool = False, **props):
144
+ """Create the component, optionally importing the tooltip stylesheet.
145
+
146
+ v5 tooltips are headless (ADR-7), so the bundled stylesheet is opt-in.
147
+ Pass ``include_tooltip_styles=True`` to emit
148
+ ``import "react-github-calendar/tooltips.css";`` once in the frontend.
149
+ """
150
+ component = super().create(*children, **props)
151
+ # Stored off-band so it is not treated as a React prop / CSS style.
152
+ object.__setattr__(
153
+ component, "_include_tooltip_styles", include_tooltip_styles
154
+ )
155
+ return component
156
+
157
+ def _get_custom_code(self) -> str | None:
158
+ """Inject the headless-tooltip stylesheet import when opted in.
159
+
160
+ v5.0.6 exposes the stylesheet via its ``exports`` field as
161
+ ``./tooltips.css`` (not ``./styles.css``); using the wrong path makes
162
+ Vite fail to resolve the import.
163
+ """
164
+ if getattr(self, "_include_tooltip_styles", False):
165
+ return 'import "react-github-calendar/tooltips.css";'
166
+ return None
167
+
168
+
169
+ # Convenience factory: ``github_calendar(username="grubersjoe")``.
170
+ github_calendar = GitHubCalendar.create
@@ -0,0 +1,82 @@
1
+ """Stub file for custom_components/reflex_react_github_calendar/github_calendar.py"""
2
+
3
+ # ------------------- DO NOT EDIT ----------------------
4
+ # This file was generated by `reflex/utils/pyi_generator.py`!
5
+ # ------------------------------------------------------
6
+ from collections.abc import Mapping, Sequence
7
+ from typing import Any, Optional
8
+ from reflex_components_core.core.breakpoints import Breakpoints
9
+ from reflex_base.event import (
10
+ EventType,
11
+ PointerEventInfo,
12
+ )
13
+ from reflex_base.vars.base import Var
14
+ from reflex.components.component import NoSSRComponent
15
+
16
+ REACT_GITHUB_CALENDAR_VERSION = "react-github-calendar@5.0.6"
17
+
18
+ class GitHubCalendar(NoSSRComponent):
19
+ @classmethod
20
+ def create(
21
+ cls,
22
+ *children,
23
+ include_tooltip_styles: bool | None = False,
24
+ username: Var[str] | str | None = None,
25
+ year: Var[int | str] | int | str | None = None,
26
+ error_message: Var[str] | str | None = None,
27
+ throw_on_error: Var[bool] | bool | None = None,
28
+ block_margin: Var[int] | int | None = None,
29
+ block_radius: Var[int] | int | None = None,
30
+ block_size: Var[int] | int | None = None,
31
+ color_scheme: Var[str] | str | None = None,
32
+ font_size: Var[int] | int | None = None,
33
+ labels: Var[dict[str, Any]] | dict[str, Any] | None = None,
34
+ max_level: Var[int] | int | None = None,
35
+ min_level: Var[int] | int | None = None,
36
+ loading: Var[bool] | bool | None = None,
37
+ show_color_legend: Var[bool] | bool | None = None,
38
+ show_month_labels: Var[bool] | bool | None = None,
39
+ show_total_count: Var[bool] | bool | None = None,
40
+ show_weekday_labels: Var[bool | list[str]] | bool | list[str] | None = None,
41
+ theme: Var[dict[str, Any]] | dict[str, Any] | None = None,
42
+ week_start: Var[int] | int | None = None,
43
+ transform_data: Any | Var[Any] | None = None,
44
+ render_block: Any | Var[Any] | None = None,
45
+ render_color_legend: Any | Var[Any] | None = None,
46
+ tooltips: Var[dict[str, Any]] | dict[str, Any] | None = None,
47
+ style: Sequence[Mapping[str, Any]]
48
+ | Mapping[str, Any]
49
+ | Var[Mapping[str, Any]]
50
+ | Breakpoints
51
+ | None = None,
52
+ key: Any | None = None,
53
+ id: Any | None = None,
54
+ ref: Var | None = None,
55
+ class_name: Any | None = None,
56
+ custom_attrs: dict[str, Any | Var] | None = None,
57
+ on_blur: Optional[EventType[()]] = None,
58
+ on_click: Optional[EventType[()] | EventType[PointerEventInfo]] = None,
59
+ on_context_menu: Optional[EventType[()] | EventType[PointerEventInfo]] = None,
60
+ on_double_click: Optional[EventType[()] | EventType[PointerEventInfo]] = None,
61
+ on_focus: Optional[EventType[()]] = None,
62
+ on_mount: Optional[EventType[()]] = None,
63
+ on_mouse_down: Optional[EventType[()]] = None,
64
+ on_mouse_enter: Optional[EventType[()]] = None,
65
+ on_mouse_leave: Optional[EventType[()]] = None,
66
+ on_mouse_move: Optional[EventType[()]] = None,
67
+ on_mouse_out: Optional[EventType[()]] = None,
68
+ on_mouse_over: Optional[EventType[()]] = None,
69
+ on_mouse_up: Optional[EventType[()]] = None,
70
+ on_scroll: Optional[EventType[()]] = None,
71
+ on_scroll_end: Optional[EventType[()]] = None,
72
+ on_unmount: Optional[EventType[()]] = None,
73
+ **props,
74
+ ) -> "GitHubCalendar":
75
+ """Create the component, optionally importing the tooltip stylesheet.
76
+
77
+ v5 tooltips are headless (ADR-7), so the bundled stylesheet is opt-in.
78
+ Pass ``include_tooltip_styles=True`` to emit
79
+ ``import "react-github-calendar/tooltips.css";`` once in the frontend."""
80
+ ...
81
+
82
+ github_calendar = GitHubCalendar.create
@@ -0,0 +1,78 @@
1
+ """Ergonomic helpers for the advanced, function-valued props (Phase 3).
2
+
3
+ ``transform_data``, ``render_block`` and ``tooltips`` accept JavaScript
4
+ functions on the React side, so they must be passed as raw function ``Var``s
5
+ (ADR-6). These recipes build those ``Var``s from a plain-Python API — the common
6
+ cases from the upstream demo — so consumers never hand-write JavaScript.
7
+
8
+ Each helper returns an ``rx.Var`` carrying a JS expression; pass it straight to
9
+ the matching prop::
10
+
11
+ from reflex_react_github_calendar import github_calendar
12
+ from reflex_react_github_calendar.recipes import last_n_days
13
+
14
+ github_calendar(username="grubersjoe", transform_data=last_n_days(90))
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ import json
20
+
21
+ import reflex as rx
22
+
23
+
24
+ def last_n_days(n: int) -> rx.Var:
25
+ """``transform_data`` recipe: keep only the last ``n`` day entries.
26
+
27
+ Mirrors the upstream ``(data) => data.slice(-90)`` example.
28
+ """
29
+ if n <= 0:
30
+ raise ValueError(f"n must be a positive number of days, got {n}")
31
+ return rx.Var(f"(data) => data.slice(-{n})")
32
+
33
+
34
+ def last_half_year() -> rx.Var:
35
+ """``transform_data`` recipe: keep entries from the last six months.
36
+
37
+ Reproduces the demo's "last half year" example by filtering activities
38
+ whose ``date`` is on or after a cutoff six months before today.
39
+ """
40
+ return rx.Var(
41
+ "(data) => {"
42
+ " const cutoff = new Date();"
43
+ " cutoff.setMonth(cutoff.getMonth() - 6);"
44
+ " return data.filter((activity) => new Date(activity.date) >= cutoff);"
45
+ " }"
46
+ )
47
+
48
+
49
+ def activity_tooltip(template: str) -> rx.Var:
50
+ """``tooltips`` recipe: a per-day tooltip from a ``{{count}}``/``{{date}}`` template.
51
+
52
+ Returns the full ``{ activity: { text } }`` tooltip object as a ``Var``.
53
+ The template is JSON-encoded so quotes and special characters are safe.
54
+ """
55
+ encoded = json.dumps(template)
56
+ text_fn = (
57
+ "(activity) => "
58
+ f"{encoded}"
59
+ ".replaceAll('{{count}}', activity.count)"
60
+ ".replaceAll('{{date}}', activity.date)"
61
+ )
62
+ return rx.Var(f"{{ activity: {{ text: {text_fn} }} }}")
63
+
64
+
65
+ def link_blocks(href_template: str) -> rx.Var:
66
+ """``render_block`` recipe: wrap each day block in a link.
67
+
68
+ ``href_template`` may contain a ``{{date}}`` placeholder, replaced with the
69
+ activity's ISO date. The block element is rendered inside an anchor via
70
+ ``React.createElement`` (React is in scope in the compiled frontend).
71
+ """
72
+ encoded = json.dumps(href_template)
73
+ return rx.Var(
74
+ "(block, activity) => React.createElement("
75
+ "'a', "
76
+ f"{{ href: {encoded}.replaceAll('{{{{date}}}}', activity.date) }}, "
77
+ "block)"
78
+ )
@@ -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,10 @@
1
+ reflex_react_github_calendar/__init__.py,sha256=4XgzNEGbt9QZm7GoDvuTEd4UyaunsZiQXaHCp_SNZns,928
2
+ reflex_react_github_calendar/domain.py,sha256=w5h4B1iLR-AdLQL_1KGs9ycJt8_OFLPWjVE9CJpruOA,1607
3
+ reflex_react_github_calendar/github_calendar.py,sha256=KlzfzXu_Eu7AhJzeUAvk8x-TFh8EOaITTc5sJgbSUpw,6940
4
+ reflex_react_github_calendar/github_calendar.pyi,sha256=GiXvNa6Qj0HPgWRsy_CcqM5mI3hv0AI20rB2cxuXjqU,3762
5
+ reflex_react_github_calendar/recipes.py,sha256=BpiZIvSOw4LGWafWmRxGwLrd8Hyj74pGbMsX_GuXXUM,2707
6
+ reflex_react_github_calendar-0.1.0.dist-info/licenses/LICENSE,sha256=C32kaF_Nae7AJDNsNGk24KPnrwvRKrMUbYeGHjcGjgw,9994
7
+ reflex_react_github_calendar-0.1.0.dist-info/METADATA,sha256=Xek4keZRcYhCQMs-hqrSWGz6Om1aN9KV-d8t9L6fh1E,7998
8
+ reflex_react_github_calendar-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
9
+ reflex_react_github_calendar-0.1.0.dist-info/top_level.txt,sha256=eGW5hgpCn6DLOrn692r7nh9SPdoVeY0lD0HUvLn5suw,29
10
+ reflex_react_github_calendar-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -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 @@
1
+ reflex_react_github_calendar