@bloom-housing/ui-components 4.0.1-alpha.61 → 4.0.1-alpha.65

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/CHANGELOG.md CHANGED
@@ -3,6 +3,49 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [4.0.1-alpha.65](https://github.com/bloom-housing/bloom/compare/@bloom-housing/ui-components@4.0.1-alpha.64...@bloom-housing/ui-components@4.0.1-alpha.65) (2022-02-16)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * add icons to unit accordions if enabled ([#2372](https://github.com/bloom-housing/bloom/issues/2372)) ([#2489](https://github.com/bloom-housing/bloom/issues/2489)) ([55e4dc9](https://github.com/bloom-housing/bloom/commit/55e4dc9a95b9fe9125153b43556fd64d06506f24))
12
+
13
+
14
+
15
+
16
+
17
+ ## [4.0.1-alpha.64](https://github.com/bloom-housing/bloom/compare/@bloom-housing/ui-components@4.0.1-alpha.63...@bloom-housing/ui-components@4.0.1-alpha.64) (2022-02-16)
18
+
19
+ **Note:** Version bump only for package @bloom-housing/ui-components
20
+
21
+
22
+
23
+
24
+
25
+ ## [4.0.1-alpha.63](https://github.com/bloom-housing/bloom/compare/@bloom-housing/ui-components@4.0.1-alpha.62...@bloom-housing/ui-components@4.0.1-alpha.63) (2022-02-15)
26
+
27
+ **Note:** Version bump only for package @bloom-housing/ui-components
28
+
29
+
30
+
31
+
32
+
33
+ ## [4.0.1-alpha.62](https://github.com/bloom-housing/bloom/compare/@bloom-housing/ui-components@4.0.1-alpha.61...@bloom-housing/ui-components@4.0.1-alpha.62) (2022-02-15)
34
+
35
+
36
+ ### Code Refactoring
37
+
38
+ * remove backend dependencies from events components, consolidate ([#2495](https://github.com/bloom-housing/bloom/issues/2495)) ([d884689](https://github.com/bloom-housing/bloom/commit/d88468965bc67c74b8b3eaced20c77472e90331f))
39
+
40
+
41
+ ### BREAKING CHANGES
42
+
43
+ * consolidated all event section components in one new component, uptake will require removing the deprecated components and uptaking EventSection
44
+
45
+
46
+
47
+
48
+
6
49
  ## [4.0.1-alpha.61](https://github.com/bloom-housing/bloom/compare/@bloom-housing/ui-components@4.0.1-alpha.60...@bloom-housing/ui-components@4.0.1-alpha.61) (2022-02-15)
7
50
 
8
51
  **Note:** Version bump only for package @bloom-housing/ui-components
package/index.ts CHANGED
@@ -116,10 +116,7 @@ export * from "./src/page_components/listing/listing_sidebar/SubmitApplication"
116
116
  export * from "./src/page_components/listing/listing_sidebar/Waitlist"
117
117
  export * from "./src/page_components/listing/listing_sidebar/WhatToExpect"
118
118
  export * from "./src/page_components/listing/listing_sidebar/events/DownloadLotteryResults"
119
- export * from "./src/page_components/listing/listing_sidebar/events/OpenHouseEvent"
120
- export * from "./src/page_components/listing/listing_sidebar/events/LotteryResultsEvent"
121
- export * from "./src/page_components/listing/listing_sidebar/events/PublicLotteryEvent"
122
- export * from "./src/page_components/listing/listing_sidebar/events/EventDateSection"
119
+ export * from "./src/page_components/listing/listing_sidebar/events/EventSection"
123
120
  export * from "./src/page_components/sign-in/FormSignIn"
124
121
  export * from "./src/page_components/sign-in/FormSignInMFAType"
125
122
  export * from "./src/page_components/sign-in/FormSignInMFACode"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bloom-housing/ui-components",
3
- "version": "4.0.1-alpha.61",
3
+ "version": "4.0.1-alpha.65",
4
4
  "author": "Sean Albert <sean.albert@exygy.com>",
5
5
  "description": "Shared user interface components for Bloom affordable housing system",
6
6
  "homepage": "https://github.com/bloom-housing/bloom/tree/master/shared/ui-components",
@@ -69,7 +69,7 @@
69
69
  "webpack": "^4.44.2"
70
70
  },
71
71
  "dependencies": {
72
- "@bloom-housing/backend-core": "^3.0.2-alpha.37",
72
+ "@bloom-housing/backend-core": "^3.0.2-alpha.40",
73
73
  "@mapbox/mapbox-sdk": "^0.13.0",
74
74
  "@types/body-scroll-lock": "^2.6.1",
75
75
  "@types/jwt-decode": "^2.2.1",
@@ -100,5 +100,5 @@
100
100
  "tailwindcss": "2.2.10",
101
101
  "typesafe-actions": "^5.1.0"
102
102
  },
103
- "gitHead": "fa057e56d890534716334baf788d631c17ae6605"
103
+ "gitHead": "f8e16ec7ae0b02796b1c83f0cc19e1953ec4d284"
104
104
  }
@@ -79,11 +79,15 @@
79
79
  }
80
80
 
81
81
  .toggle-header {
82
- @apply font-sans;
83
- @apply text-tiny;
84
82
  @apply bg-primary-light;
85
83
  @apply p-4;
86
- @apply text-gray-800;
87
84
  @apply border-b;
88
85
  @apply border-primary;
86
+ display: flex;
87
+ justify-content: space-between;
88
+ .toggle-header-content {
89
+ @apply font-sans;
90
+ @apply text-tiny;
91
+ @apply text-gray-800;
92
+ }
89
93
  }
@@ -3,7 +3,7 @@ import { t } from "./translator"
3
3
  import { UnitSummary } from "@bloom-housing/backend-core/types"
4
4
 
5
5
  export const unitSummariesTable = (summaries: UnitSummary[]) => {
6
- const unitSummaries = summaries.map((unitSummary) => {
6
+ const unitSummaries = summaries?.map((unitSummary) => {
7
7
  const unitPluralization = unitSummary.totalAvailable == 1 ? t("t.unit") : t("t.units")
8
8
  const minIncome =
9
9
  unitSummary.minIncomeRange.min == unitSummary.minIncomeRange.max ? (
@@ -136,6 +136,7 @@ export interface IconProps {
136
136
  className?: string
137
137
  fill?: string
138
138
  ariaHidden?: boolean
139
+ dataTestId?: string
139
140
  }
140
141
 
141
142
  const Icon = (props: IconProps) => {
@@ -147,7 +148,11 @@ const Icon = (props: IconProps) => {
147
148
  const SpecificIcon = IconMap[props.symbol]
148
149
 
149
150
  return (
150
- <span className={wrapperClasses.join(" ")} aria-hidden={props.ariaHidden}>
151
+ <span
152
+ className={wrapperClasses.join(" ")}
153
+ aria-hidden={props.ariaHidden}
154
+ data-test-id={props.dataTestId ?? null}
155
+ >
151
156
  <SpecificIcon fill={props.fill ? props.fill : undefined} />
152
157
  </span>
153
158
  )
@@ -1,10 +1,11 @@
1
- import * as React from "react"
1
+ import React, { useState } from "react"
2
2
  import { nanoid } from "nanoid"
3
3
  import { MinMax, UnitSummary, Unit } from "@bloom-housing/backend-core/types"
4
4
 
5
5
  import { StandardTable } from "../../tables/StandardTable"
6
6
  import { t } from "../../helpers/translator"
7
7
  import { numberOrdinal } from "../../helpers/numberOrdinal"
8
+ import { Icon, IconFillColors } from "../../icons/Icon"
8
9
 
9
10
  const formatRange = (range: MinMax, ordinalize?: boolean) => {
10
11
  let min: string | number = range.min
@@ -34,6 +35,7 @@ interface UnitTablesProps {
34
35
  }
35
36
 
36
37
  const UnitTables = (props: UnitTablesProps) => {
38
+ const [accordionOpen, setAccordionOpen] = useState(false)
37
39
  const unitSummaries = props.unitSummaries || []
38
40
 
39
41
  const unitsHeaders = {
@@ -43,9 +45,9 @@ const UnitTables = (props: UnitTablesProps) => {
43
45
  floor: "t.floor",
44
46
  }
45
47
 
46
- const toggleTable = (event: React.MouseEvent) => {
48
+ const toggleTable = () => {
47
49
  if (!props.disableAccordion) {
48
- event.currentTarget.parentElement?.querySelector(".unit-table")?.classList?.toggle("hidden")
50
+ setAccordionOpen(!accordionOpen)
49
51
  }
50
52
  }
51
53
 
@@ -97,16 +99,39 @@ const UnitTables = (props: UnitTablesProps) => {
97
99
  return (
98
100
  <div key={uniqKey} className="mb-4">
99
101
  <button onClick={toggleTable} className={buttonClasses.join(" ")}>
100
- <h3 className="toggle-header">
101
- <strong>{t("listings.unitTypes." + unitSummary.unitType.name)}</strong>:&nbsp;
102
- {unitsLabel(units)}
103
- {areaRangeSection}
104
- {floorSection}
105
- </h3>
102
+ <div className={`toggle-header ${!props.disableAccordion && "pb-3"}`}>
103
+ <h3 className={"toggle-header-content"}>
104
+ <strong>{t("listings.unitTypes." + unitSummary.unitType.name)}</strong>:&nbsp;
105
+ {unitsLabel(units)}
106
+ {areaRangeSection}
107
+ {floorSection}
108
+ </h3>
109
+ {!props.disableAccordion && (
110
+ <>
111
+ {accordionOpen ? (
112
+ <Icon
113
+ symbol={"closeSmall"}
114
+ size={"base"}
115
+ fill={IconFillColors.primary}
116
+ dataTestId={"unit-table-accordion-close"}
117
+ />
118
+ ) : (
119
+ <Icon
120
+ symbol={"arrowDown"}
121
+ size={"base"}
122
+ fill={IconFillColors.primary}
123
+ dataTestId={"unit-table-accordion-open"}
124
+ />
125
+ )}
126
+ </>
127
+ )}
128
+ </div>
106
129
  </button>
107
- <div className="unit-table hidden">
108
- <StandardTable headers={unitsHeaders} data={unitsFormatted} />
109
- </div>
130
+ {accordionOpen && (
131
+ <div className="unit-table">
132
+ <StandardTable headers={unitsHeaders} data={unitsFormatted} />
133
+ </div>
134
+ )}
110
135
  </div>
111
136
  )
112
137
  })}
@@ -1,30 +1,29 @@
1
1
  import * as React from "react"
2
- import { ListingEvent } from "@bloom-housing/backend-core/types"
3
2
  import { t } from "../../../../helpers/translator"
4
- import dayjs from "dayjs"
5
3
 
6
- const DownloadLotteryResults = (props: { event: ListingEvent; pdfUrl: string }) => {
7
- const { event, pdfUrl } = props
8
- const eventUrl = event ? pdfUrl : null
4
+ type DownloadLotteryResultsProps = {
5
+ resultsDate?: string
6
+ buttonText?: string
7
+ pdfURL?: string
8
+ }
9
+
10
+ const DownloadLotteryResults = (props: DownloadLotteryResultsProps) => {
11
+ if (!props.pdfURL) return null
9
12
  return (
10
- <>
11
- {eventUrl && (
12
- <section className="aside-block text-center">
13
- <h2 className="text-caps pb-4">{t("listings.lotteryResults.header")}</h2>
14
- <p className="uppercase text-gray-800 text-tiny font-semibold pb-4">
15
- {dayjs(event.startTime).format("MMMM D, YYYY")}
16
- </p>
17
- <a
18
- className="button is-primary w-full mb-2"
19
- href={eventUrl}
20
- title={t("listings.lotteryResults.downloadResults")}
21
- target="_blank"
22
- >
23
- {t("listings.lotteryResults.downloadResults")}
24
- </a>
25
- </section>
13
+ <section className="aside-block text-center">
14
+ <h2 className="text-caps pb-4">{t("listings.lotteryResults.header")}</h2>
15
+ {props.resultsDate && (
16
+ <p className="uppercase text-gray-800 text-tiny font-semibold pb-4">{props.resultsDate}</p>
26
17
  )}
27
- </>
18
+ <a
19
+ className="button is-primary w-full mb-2"
20
+ href={props.pdfURL}
21
+ title={props.buttonText}
22
+ target="_blank"
23
+ >
24
+ {props.buttonText ?? t("listings.lotteryResults.downloadResults")}
25
+ </a>
26
+ </section>
28
27
  )
29
28
  }
30
29
 
@@ -0,0 +1,54 @@
1
+ import * as React from "react"
2
+
3
+ export type EventType = {
4
+ timeString?: string
5
+ dateString?: string
6
+ linkURL?: string
7
+ linkText?: string
8
+ note?: string | React.ReactNode
9
+ }
10
+
11
+ type EventSectionProps = {
12
+ events: EventType[]
13
+ headerText?: string
14
+ sectionHeader?: boolean
15
+ }
16
+
17
+ const EventSection = (props: EventSectionProps) => {
18
+ if (!props.events.length) return null
19
+ return (
20
+ <section className="aside-block">
21
+ {props.headerText && (
22
+ <h4 className={props.sectionHeader ? "text-caps-underline" : "text-caps-tiny"}>
23
+ {props.headerText}
24
+ </h4>
25
+ )}
26
+ {props.events.map((event, index) => (
27
+ <div key={`events-${index}`} className={`${index !== props.events.length - 1 && "pb-3"}`}>
28
+ {event.dateString && (
29
+ <p className="text text-gray-800 pb-2 flex justify-between items-center">
30
+ <span className="inline-block text-tiny uppercase">{event.dateString}</span>
31
+ {event.timeString && (
32
+ <span className="inline-block text-sm font-bold ml-5 font-alt-sans">
33
+ {event.timeString}
34
+ </span>
35
+ )}
36
+ </p>
37
+ )}
38
+ {event.linkURL && event.linkText && (
39
+ <p className="pb-2 text-tiny">
40
+ <a href={event.linkURL}>{event.linkText}</a>
41
+ </p>
42
+ )}
43
+ {event.note && (
44
+ <p className={`text-tiny text-gray-700 ${index !== props.events.length - 1 && "pb-3"}`}>
45
+ {event.note}
46
+ </p>
47
+ )}
48
+ </div>
49
+ ))}
50
+ </section>
51
+ )
52
+ }
53
+
54
+ export { EventSection as default, EventSection }
@@ -1,25 +0,0 @@
1
- import * as React from "react"
2
- import { ListingEvent } from "@bloom-housing/backend-core/types"
3
- import dayjs from "dayjs"
4
-
5
- const EventDateSection = (props: { event: ListingEvent }) => {
6
- const getRangeString = () => {
7
- const startTime = dayjs(props.event.startTime).format("hh:mma")
8
- const endTime = dayjs(props.event.endTime).format("hh:mma")
9
- return startTime === endTime ? startTime : `${startTime} - ${endTime}`
10
- }
11
- return (
12
- <>
13
- {props.event.startTime && (
14
- <p className="text text-gray-800 pb-3 flex justify-between items-center">
15
- <span className="inline-block text-tiny uppercase">
16
- {dayjs(props.event.startTime).format("MMMM D, YYYY")}
17
- </span>
18
- <span className="inline-block text-sm font-bold">{getRangeString()}</span>
19
- </p>
20
- )}
21
- </>
22
- )
23
- }
24
-
25
- export { EventDateSection as default, EventDateSection }
@@ -1,26 +0,0 @@
1
- import * as React from "react"
2
- import { ListingEvent } from "@bloom-housing/backend-core/types"
3
- import { t } from "../../../../helpers/translator"
4
- import dayjs from "dayjs"
5
-
6
- const LotteryResultsEvent = (props: { event: ListingEvent }) => {
7
- const { event } = props
8
- return (
9
- <section className="aside-block">
10
- <h4 className="text-caps-underline">{t("listings.lotteryResults.header")}</h4>
11
- <p className="text text-gray-800 pb-3 flex justify-between items-center">
12
- <span className="inline-block">{dayjs(props.event.startTime).format("MMMM D, YYYY")}</span>
13
- </p>
14
- {event.note && <p className="text text-gray-600">{event.note}</p>}
15
- {!event.note && (
16
- <p className="text-tiny text-gray-600">
17
- {t("listings.lotteryResults.completeResultsWillBePosted", {
18
- hour: dayjs(props.event.startTime).format("h a"),
19
- })}
20
- </p>
21
- )}
22
- </section>
23
- )
24
- }
25
-
26
- export { LotteryResultsEvent as default, LotteryResultsEvent }
@@ -1,27 +0,0 @@
1
- import * as React from "react"
2
- import { ListingEvent } from "@bloom-housing/backend-core/types"
3
- import { EventDateSection } from "./EventDateSection"
4
- import { t } from "../../../../helpers/translator"
5
-
6
- const OpenHouseEvent = (props: { events: ListingEvent[] }) => {
7
- return (
8
- <section className="aside-block">
9
- <h4 className="text-caps-tiny">{t("listings.openHouseEvent.header")}</h4>
10
- {props.events.map((openHouseEvent, index) => (
11
- <div key={`openHouses-${index}`}>
12
- <EventDateSection event={openHouseEvent} />
13
- {openHouseEvent.url && (
14
- <p className="text text-gray-800 pb-3">
15
- <a href={openHouseEvent.url}>
16
- {openHouseEvent.label || t("listings.openHouseEvent.seeVideo")}
17
- </a>
18
- </p>
19
- )}
20
- {openHouseEvent.note && <p className="text-tiny text-gray-600">{openHouseEvent.note}</p>}
21
- </div>
22
- ))}
23
- </section>
24
- )
25
- }
26
-
27
- export { OpenHouseEvent as default, OpenHouseEvent }
@@ -1,22 +0,0 @@
1
- import * as React from "react"
2
- import { ListingEvent } from "@bloom-housing/backend-core/types"
3
- import { t } from "../../../../helpers/translator"
4
- import { EventDateSection } from "./EventDateSection"
5
-
6
- const PublicLotteryEvent = (props: { event: ListingEvent }) => {
7
- const { event } = props
8
- return (
9
- <section className="aside-block">
10
- <h4 className="text-caps-underline">{t("listings.publicLottery.header")}</h4>
11
- <EventDateSection event={props.event} />
12
- {event.url && (
13
- <p className="text text-gray-800 pb-3">
14
- <a href={event.url}>{t("listings.publicLottery.seeVideo")}</a>
15
- </p>
16
- )}
17
- {event.note && <p className="text-tiny text-gray-600">{event.note}</p>}
18
- </section>
19
- )
20
- }
21
-
22
- export { PublicLotteryEvent as default, PublicLotteryEvent }