Skip to content

Commit

Permalink
Format with ruff + prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Archmonger committed Oct 5, 2024
1 parent 169e2dc commit 5ffc34f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 45 deletions.
38 changes: 19 additions & 19 deletions src/js/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ import commonjs from "rollup-plugin-commonjs";
import replace from "rollup-plugin-replace";

export default {
input: "src/index.js",
output: {
file: "../reactpy_router/static/bundle.js",
format: "esm",
},
plugins: [
resolve(),
commonjs(),
replace({
"process.env.NODE_ENV": JSON.stringify("production"),
}),
],
onwarn: function (warning) {
if (warning.code === "THIS_IS_UNDEFINED") {
// skip warning where `this` is undefined at the top level of a module
return;
}
console.warn(warning.message);
},
input: "src/index.js",
output: {
file: "../reactpy_router/static/bundle.js",
format: "esm",
},
plugins: [
resolve(),
commonjs(),
replace({
"process.env.NODE_ENV": JSON.stringify("production"),
}),
],
onwarn: function (warning) {
if (warning.code === "THIS_IS_UNDEFINED") {
// skip warning where `this` is undefined at the top level of a module
return;
}
console.warn(warning.message);
},
};
40 changes: 20 additions & 20 deletions src/js/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@ import React from "react";
import ReactDOM from "react-dom";

export function bind(node) {
return {
create: (type, props, children) =>
React.createElement(type, props, ...children),
render: (element) => {
ReactDOM.render(element, node);
},
unmount: () => ReactDOM.unmountComponentAtNode(node),
};
return {
create: (type, props, children) =>
React.createElement(type, props, ...children),
render: (element) => {
ReactDOM.render(element, node);
},
unmount: () => ReactDOM.unmountComponentAtNode(node),
};
}

export function History({ onChange }) {
// Capture changes to the browser's history
React.useEffect(() => {
const listener = () => {
onChange({
pathname: window.location.pathname,
search: window.location.search,
});
};
window.addEventListener("popstate", listener);
return () => window.removeEventListener("popstate", listener);
});
return null;
// Capture changes to the browser's history
React.useEffect(() => {
const listener = () => {
onChange({
pathname: window.location.pathname,
search: window.location.search,
});
};
window.addEventListener("popstate", listener);
return () => window.removeEventListener("popstate", listener);
});
return null;
}
8 changes: 2 additions & 6 deletions src/reactpy_router/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,13 @@ def __hash__(self) -> int:
class Router(Protocol[R_contra]):
"""Return a component that renders the first matching route"""

def __call__(
self, *routes: R_contra, select: Literal["first", "all"] = "first"
) -> ComponentType:
...
def __call__(self, *routes: R_contra, select: Literal["first", "all"] = "first") -> ComponentType: ...


class RouteCompiler(Protocol[R_contra]):
"""Compile a route into a resolver that can be matched against a path"""

def __call__(self, route: R_contra) -> RouteResolver:
...
def __call__(self, route: R_contra) -> RouteResolver: ...


class RouteResolver(Protocol):
Expand Down

0 comments on commit 5ffc34f

Please sign in to comment.