@bloom-housing/ui-components 4.0.1-alpha.62 → 4.0.1-alpha.66

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,44 @@
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.66](https://github.com/bloom-housing/bloom/compare/@bloom-housing/ui-components@4.0.1-alpha.65...@bloom-housing/ui-components@4.0.1-alpha.66) (2022-02-16)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * use the correct AlertBox component for preview listing notice ([#2497](https://github.com/bloom-housing/bloom/issues/2497)) ([f985c44](https://github.com/bloom-housing/bloom/commit/f985c444aaed31504a1e1ce7173c6e15194e2af6))
12
+
13
+
14
+
15
+
16
+
17
+ ## [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)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * 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))
23
+
24
+
25
+
26
+
27
+
28
+ ## [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)
29
+
30
+ **Note:** Version bump only for package @bloom-housing/ui-components
31
+
32
+
33
+
34
+
35
+
36
+ ## [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)
37
+
38
+ **Note:** Version bump only for package @bloom-housing/ui-components
39
+
40
+
41
+
42
+
43
+
6
44
  ## [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)
7
45
 
8
46
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bloom-housing/ui-components",
3
- "version": "4.0.1-alpha.62",
3
+ "version": "4.0.1-alpha.66",
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.38",
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": "d1ce250a3db83007034b09cd1dfd449e4d1575d6"
103
+ "gitHead": "23e64f920ddd9dc8adba6ce4472e7c960d9c1278"
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
  )
@@ -13,6 +13,7 @@
13
13
  @apply flex-1;
14
14
  @apply flex;
15
15
  @apply items-center;
16
+ line-height: 1rem;
16
17
  }
17
18
 
18
19
  &.narrow {
@@ -79,7 +80,6 @@
79
80
 
80
81
  .alert-box__close {
81
82
  @apply text-3xl;
82
- line-height: 1rem;
83
83
  right: 1rem;
84
84
  @apply ml-3;
85
85
  @apply p-0;
@@ -52,6 +52,7 @@ const AlertBox = (props: AlertBoxProps) => {
52
52
  size="medium"
53
53
  symbol={icons[props.type || "alert"]}
54
54
  fill={props.inverted ? IconFillColors.white : undefined}
55
+ ariaHidden={true}
55
56
  />
56
57
  </span>
57
58
  <span className="alert-box__body">
@@ -63,8 +64,9 @@ const AlertBox = (props: AlertBoxProps) => {
63
64
  <button
64
65
  className={`alert-box__close ${props.inverted ? "text-white" : ""}`}
65
66
  onClick={onClose}
67
+ aria-label="close alert"
66
68
  >
67
- &times;
69
+ <span aria-hidden={true}>&times;</span>
68
70
  </button>
69
71
  )}
70
72
  </div>
@@ -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
  })}