@local-civics/mgmt-ui 0.1.74 → 0.1.76

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.
package/dist/index.d.ts CHANGED
@@ -5,22 +5,6 @@ import * as React from 'react';
5
5
  * NavbarProps
6
6
  */
7
7
  interface NavbarProps {
8
- active: string;
9
- navigate: (to: string) => void;
10
- onLogout: () => void;
11
- onSwitchAccounts?: () => void;
12
- }
13
- /**
14
- * Navbar
15
- * @param props
16
- * @constructor
17
- */
18
- declare const Navbar: (props: NavbarProps) => JSX.Element;
19
-
20
- /**
21
- * NavbarProps
22
- */
23
- interface NestedNavbarProps {
24
8
  active: string;
25
9
  version: string;
26
10
  image: string;
@@ -35,7 +19,7 @@ interface NestedNavbarProps {
35
19
  onLogout: () => void;
36
20
  onSwitchAccounts?: () => void;
37
21
  }
38
- declare function NestedNavbar(props: NestedNavbarProps): JSX.Element;
22
+ declare function Navbar(props: NavbarProps): JSX.Element;
39
23
 
40
24
  /**
41
25
  * AccountItem
@@ -656,12 +640,12 @@ declare const AdminProvider: (props: AdminProviderProps) => JSX.Element;
656
640
  * AppProps
657
641
  */
658
642
  type AppProps = {
659
- loading: boolean;
660
- account: string;
661
- accounts: AccountItem[];
662
- navbar: React.ReactElement<NestedNavbarProps>;
643
+ loading?: boolean;
644
+ account?: string;
645
+ accounts?: AccountItem[];
646
+ navbar?: React.ReactElement<NavbarProps>;
663
647
  page: React.ReactNode;
664
- onAccountChange: (account: string) => Promise<void>;
648
+ onAccountChange?: (account: string) => Promise<void>;
665
649
  };
666
650
  /**
667
651
  * App
@@ -670,4 +654,4 @@ type AppProps = {
670
654
  */
671
655
  declare const App: (props: AppProps) => JSX.Element;
672
656
 
673
- export { AccountItem, AdminProvider, AdminProviderProps, App, AppProps, Badge, BadgeClass, BadgeItem, BadgeProps, BadgeUserItem, Badges, BadgesProps, Class, ClassItem, ClassProps, Classes, ClassesProps, Dashboard, DashboardClass, DashboardProps, Home, HomeProps, Lesson, LessonClass, LessonItem, LessonProps, LessonUserItem, Lessons, LessonsProps, MemberItem, Navbar, NavbarProps, NestedNavbar, NestedNavbarProps, Organization, OrganizationProps, People, PeopleProps, StartAnonymousLesson, StartAnonymousLessonProps, Student, StudentProps, SwitchAccount, SwitchAccountProps, TrialHome, TrialHomeProps, TrialRegistration, TrialRegistrationProps, UserItem };
657
+ export { AccountItem, AdminProvider, AdminProviderProps, App, AppProps, Badge, BadgeClass, BadgeItem, BadgeProps, BadgeUserItem, Badges, BadgesProps, Class, ClassItem, ClassProps, Classes, ClassesProps, Dashboard, DashboardClass, DashboardProps, Home, HomeProps, Lesson, LessonClass, LessonItem, LessonProps, LessonUserItem, Lessons, LessonsProps, MemberItem, Navbar, NavbarProps, Organization, OrganizationProps, People, PeopleProps, StartAnonymousLesson, StartAnonymousLessonProps, Student, StudentProps, SwitchAccount, SwitchAccountProps, TrialHome, TrialHomeProps, TrialRegistration, TrialRegistrationProps, UserItem };
package/dist/index.js CHANGED
@@ -34,65 +34,6 @@ function _interopNamespaceDefault(e) {
34
34
  var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
35
35
  var papa__namespace = /*#__PURE__*/_interopNamespaceDefault(papa);
36
36
 
37
- const useStyles$p = core.createStyles((theme) => ({
38
- link: {
39
- width: 50,
40
- height: 50,
41
- borderRadius: theme.radius.md,
42
- display: "flex",
43
- alignItems: "center",
44
- justifyContent: "center",
45
- color: theme.colorScheme === "dark" ? theme.colors.dark[0] : theme.colors.gray[7],
46
- "&:hover": {
47
- backgroundColor: theme.colorScheme === "dark" ? theme.colors.dark[5] : theme.colors.gray[0]
48
- }
49
- },
50
- active: {
51
- "&, &:hover": {
52
- backgroundColor: theme.fn.variant({ variant: "light", color: theme.primaryColor }).background,
53
- color: theme.fn.variant({ variant: "light", color: theme.primaryColor }).color
54
- }
55
- }
56
- }));
57
- const data$1 = [
58
- { icon: icons.IconHome2, label: "Home", href: "/home" },
59
- { icon: icons.IconGauge, label: "Dashboard", href: "/dashboard" },
60
- { icon: icons.IconCategory2, label: "Classes", href: "/classes" },
61
- { icon: icons.IconAlbum, label: "Badges", href: "/badges" },
62
- { icon: icons.IconLambda, label: "Lessons", href: "/lessons" }
63
- ];
64
- const NavbarLink = ({ icon: Icon, label, active, onClick }) => {
65
- const { classes, cx } = useStyles$p();
66
- return /* @__PURE__ */ React__namespace.createElement(core.Tooltip, { label, position: "right", transitionDuration: 0 }, /* @__PURE__ */ React__namespace.createElement(core.UnstyledButton, { onClick, className: cx(classes.link, { [classes.active]: active }) }, /* @__PURE__ */ React__namespace.createElement(Icon, { stroke: 1.5 })));
67
- };
68
- const Navbar = (props) => {
69
- const links = data$1.map((link) => /* @__PURE__ */ React__namespace.createElement(
70
- NavbarLink,
71
- {
72
- key: link.label,
73
- label: link.label,
74
- icon: link.icon,
75
- active: link.label === props.active,
76
- onClick: () => props.navigate(link.href)
77
- }
78
- ));
79
- return /* @__PURE__ */ React__namespace.createElement(core.Navbar, { width: { base: 80 }, p: "md" }, /* @__PURE__ */ React__namespace.createElement(core.Center, null, /* @__PURE__ */ React__namespace.createElement(core.Avatar, { color: "blue", radius: "sm" }, /* @__PURE__ */ React__namespace.createElement("div", { style: { width: 15, marginLeft: "auto", marginRight: "auto" } }, /* @__PURE__ */ React__namespace.createElement(core.Image, { fit: "contain", src: "https://cdn.localcivics.io/brand/l.png" })))), /* @__PURE__ */ React__namespace.createElement(core.Navbar.Section, { grow: true, mt: 50 }, /* @__PURE__ */ React__namespace.createElement(core.Stack, { justify: "center", spacing: 0 }, links)), /* @__PURE__ */ React__namespace.createElement(core.Navbar.Section, null, /* @__PURE__ */ React__namespace.createElement(core.Stack, { justify: "center", spacing: 0 }, /* @__PURE__ */ React__namespace.createElement(
80
- NavbarLink,
81
- {
82
- icon: icons.IconSwitchHorizontal,
83
- label: "Switch accounts",
84
- onClick: props.onSwitchAccounts
85
- }
86
- ), /* @__PURE__ */ React__namespace.createElement(
87
- NavbarLink,
88
- {
89
- icon: icons.IconLogout,
90
- label: "Logout",
91
- onClick: props.onLogout
92
- }
93
- ))));
94
- };
95
-
96
37
  var __defProp$9 = Object.defineProperty;
97
38
  var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
98
39
  var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
@@ -353,7 +294,7 @@ const data = [
353
294
  ]
354
295
  }
355
296
  ];
356
- function NestedNavbar(props) {
297
+ function Navbar(props) {
357
298
  const { classes, cx } = useStyles$m();
358
299
  const [burgerOpen, setBurgerOpen] = React__namespace.useState(false);
359
300
  const toggle = () => setBurgerOpen(!burgerOpen);
@@ -2784,7 +2725,15 @@ const TrialRegistration = (props) => {
2784
2725
  const [firstName, setFirstName] = React__namespace.useState("");
2785
2726
  const [lastName, setLastName] = React__namespace.useState("");
2786
2727
  const [interests, setInterests] = React__namespace.useState({});
2787
- return /* @__PURE__ */ React__namespace.createElement("div", { className: classes.wrapper }, /* @__PURE__ */ React__namespace.createElement(core.SimpleGrid, { maw: 960, ml: "auto", mr: "auto", cols: 1, spacing: 15, breakpoints: [{ maxWidth: "sm", cols: 1 }] }, /* @__PURE__ */ React__namespace.createElement("div", null, /* @__PURE__ */ React__namespace.createElement(core.Title, { className: classes.title }, "Trial Educator"), /* @__PURE__ */ React__namespace.createElement(core.Text, { className: classes.description, mt: "sm", mb: 30 }, "Try out a some of the features we can bring to your classroom. No commitment required.")), /* @__PURE__ */ React__namespace.createElement("div", { className: classes.form }, /* @__PURE__ */ React__namespace.createElement(core.Group, { mb: "md", spacing: "md", grow: true }, /* @__PURE__ */ React__namespace.createElement(
2728
+ return /* @__PURE__ */ React__namespace.createElement("div", { className: classes.wrapper }, /* @__PURE__ */ React__namespace.createElement(core.SimpleGrid, { maw: 960, ml: "auto", mr: "auto", cols: 1, spacing: 15, breakpoints: [{ maxWidth: "sm", cols: 1 }] }, /* @__PURE__ */ React__namespace.createElement(core.Group, { spacing: "sm" }, /* @__PURE__ */ React__namespace.createElement(
2729
+ core.Image,
2730
+ {
2731
+ height: 100,
2732
+ width: "auto",
2733
+ fit: "contain",
2734
+ src: "https://cdn.localcivics.io/brand/l.png"
2735
+ }
2736
+ ), /* @__PURE__ */ React__namespace.createElement("div", null, /* @__PURE__ */ React__namespace.createElement(core.Title, { className: classes.title }, "Trial Educator"), /* @__PURE__ */ React__namespace.createElement(core.Text, { className: classes.description, mt: "sm" }, "Try out a few of the features we can bring to your classroom. No commitment required."))), /* @__PURE__ */ React__namespace.createElement("div", { className: classes.form }, /* @__PURE__ */ React__namespace.createElement(core.Group, { mb: "md", spacing: "md", grow: true }, /* @__PURE__ */ React__namespace.createElement(
2788
2737
  core.TextInput,
2789
2738
  {
2790
2739
  label: "First Name",
@@ -2856,17 +2805,17 @@ var __spreadValues = (a, b) => {
2856
2805
  return a;
2857
2806
  };
2858
2807
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
2859
- const useStyles = core.createStyles((theme) => ({
2808
+ const useStyles = core.createStyles((theme, props) => ({
2860
2809
  footer: {
2861
2810
  paddingTop: theme.spacing.md,
2862
2811
  paddingBottom: theme.spacing.md,
2863
- paddingLeft: theme.spacing.md,
2812
+ paddingLeft: props.navbar ? theme.spacing.md : 0,
2864
2813
  backgroundColor: theme.colorScheme === "dark" ? theme.colors.dark[6] : theme.colors.gray[0],
2865
2814
  borderTop: `1px solid ${theme.colorScheme === "dark" ? theme.colors.dark[5] : theme.colors.gray[2]}`,
2866
2815
  [theme.fn.largerThan("sm")]: {
2867
2816
  paddingTop: theme.spacing.xl * 2,
2868
2817
  paddingBottom: theme.spacing.xl * 2,
2869
- paddingLeft: theme.spacing.xl * 13
2818
+ paddingLeft: props.navbar ? theme.spacing.xl * 13 : 0
2870
2819
  }
2871
2820
  },
2872
2821
  logo: {
@@ -2938,14 +2887,14 @@ const useStyles = core.createStyles((theme) => ({
2938
2887
  }
2939
2888
  }));
2940
2889
  const App = (props) => {
2941
- const { classes } = useStyles();
2890
+ const { classes } = useStyles(props);
2942
2891
  const account = useAccount(props.account, props.accounts, props.onAccountChange);
2943
2892
  return /* @__PURE__ */ React__namespace.createElement(
2944
2893
  core.AppShell,
2945
2894
  {
2946
2895
  padding: "xs",
2947
- navbar: /* @__PURE__ */ React__namespace.createElement(
2948
- NestedNavbar,
2896
+ navbar: props.navbar && /* @__PURE__ */ React__namespace.createElement(
2897
+ Navbar,
2949
2898
  __spreadProps(__spreadValues({}, props.navbar.props), {
2950
2899
  onSwitchAccounts: account.accounts && account.accounts.length > 1 ? () => account.setChangeModalOpen(true) : void 0
2951
2900
  })
@@ -2992,7 +2941,7 @@ const App = (props) => {
2992
2941
  })
2993
2942
  },
2994
2943
  /* @__PURE__ */ React__namespace.createElement("div", { style: { position: "relative" } }, (props.loading || account.opened) && /* @__PURE__ */ React__namespace.createElement(core.Center, { style: { height: 400 } }, /* @__PURE__ */ React__namespace.createElement(core.Loader, null)), !props.loading && !account.opened && props.page),
2995
- /* @__PURE__ */ React__namespace.createElement(
2944
+ !!account.accounts && !!account.account && /* @__PURE__ */ React__namespace.createElement(
2996
2945
  SwitchAccount,
2997
2946
  {
2998
2947
  opened: account.opened,
@@ -3021,6 +2970,9 @@ const useAccount = (account, accounts, onAccountChange) => {
3021
2970
  setChangeModalOpen,
3022
2971
  onAccountChange: (account2) => {
3023
2972
  setLoading(true);
2973
+ if (!onAccountChange) {
2974
+ return;
2975
+ }
3024
2976
  onAccountChange(account2).then(() => {
3025
2977
  setActive(account2);
3026
2978
  setLoading(false);
@@ -3049,7 +3001,6 @@ exports.Home = Home;
3049
3001
  exports.Lesson = Lesson;
3050
3002
  exports.Lessons = Lessons;
3051
3003
  exports.Navbar = Navbar;
3052
- exports.NestedNavbar = NestedNavbar;
3053
3004
  exports.Organization = Organization;
3054
3005
  exports.People = People;
3055
3006
  exports.StartAnonymousLesson = StartAnonymousLesson;