@bloom-housing/ui-components 5.1.1-alpha.2 → 5.1.1-alpha.3

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,34 @@
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
+ ## [5.1.1-alpha.3](https://github.com/bloom-housing/bloom/compare/@bloom-housing/ui-components@5.1.1-alpha.2...@bloom-housing/ui-components@5.1.1-alpha.3) (2022-08-03)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **expandabletext:** add required strings to expandable text ([03bbc46](https://github.com/bloom-housing/bloom/commit/03bbc46b4f8f910efef0a1f984717da0a65794ed))
12
+ * **expandabletext:** fix stories with passing req prop ([057d8fe](https://github.com/bloom-housing/bloom/commit/057d8feb038e07bb3d6784d1d6d4d068ba72460c)), closes [#2925](https://github.com/bloom-housing/bloom/issues/2925)
13
+ * **expandabletext:** fix tests; remove test prop ([28af8fc](https://github.com/bloom-housing/bloom/commit/28af8fc319190c50b2751d29c251e472e48e6971))
14
+ * option typing with import ([dc195f8](https://github.com/bloom-housing/bloom/commit/dc195f8acb8850bab11eafc80a2cea3f8b6e0de5))
15
+
16
+
17
+ ### Features
18
+
19
+ * **expandabletext:** fix a broken ci check; fix a prop name ([e839c81](https://github.com/bloom-housing/bloom/commit/e839c811b237164b1cd26bbc888db512f66bc6b0))
20
+ * **expandabletext:** fix type usage ([1a406fe](https://github.com/bloom-housing/bloom/commit/1a406fe7c19639e28bb1fdc19fd9e58a25c8bfd1)), closes [#2925](https://github.com/bloom-housing/bloom/issues/2925)
21
+ * **expandabletext:** remove translations;pass markdown props through component ([e21e88a](https://github.com/bloom-housing/bloom/commit/e21e88a5be527ec860b3515c1dc545a186713e06)), closes [#2925](https://github.com/bloom-housing/bloom/issues/2925)
22
+
23
+
24
+ ### BREAKING CHANGES
25
+
26
+ * **expandabletext:** In uses of ExpandableText component, the translations are now being passed down
27
+ instead of done within the component. Any options for the Markdown component used within
28
+ ExpandableText also needs to be passed
29
+
30
+
31
+
32
+
33
+
6
34
  ## [5.1.1-alpha.2](https://github.com/bloom-housing/bloom/compare/@bloom-housing/ui-components@5.1.1-alpha.1...@bloom-housing/ui-components@5.1.1-alpha.2) (2022-08-01)
7
35
 
8
36
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bloom-housing/ui-components",
3
- "version": "5.1.1-alpha.2",
3
+ "version": "5.1.1-alpha.3",
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",
@@ -112,5 +112,5 @@
112
112
  "ts-jest": "^26.4.1",
113
113
  "typesafe-actions": "^5.1.0"
114
114
  },
115
- "gitHead": "011a850750b1c9a53a364984e1216797ff25351c"
115
+ "gitHead": "47d2dccffb21958f87769e4c46cfa3c977a5bf30"
116
116
  }
@@ -1,6 +1,5 @@
1
1
  import React, { useState } from "react"
2
- import Markdown from "markdown-to-jsx"
3
- import { t } from "../helpers/translator"
2
+ import Markdown, { MarkdownOptions } from "markdown-to-jsx"
4
3
  import "./ExpandableText.scss"
5
4
 
6
5
  export interface ExpandableTextProps {
@@ -8,6 +7,11 @@ export interface ExpandableTextProps {
8
7
  expand?: boolean
9
8
  maxLength?: number
10
9
  className?: string
10
+ strings: {
11
+ readMore: string
12
+ readLess: string
13
+ }
14
+ markdownProps?: MarkdownOptions
11
15
  }
12
16
 
13
17
  const getText = (text: string, expanded: boolean, maxLength: number) => {
@@ -22,10 +26,14 @@ const getText = (text: string, expanded: boolean, maxLength: number) => {
22
26
  return position > 0 ? text.substring(0, position) + "..." : text.substring(0, maxLength) + "..."
23
27
  }
24
28
 
25
- const moreLessButton = (expanded: boolean, setExpanded: (newValue: boolean) => void) => {
29
+ const moreLessButton = (
30
+ expanded: boolean,
31
+ setExpanded: (newValue: boolean) => void,
32
+ strings: ExpandableTextProps["strings"]
33
+ ) => {
26
34
  return (
27
35
  <span className="button-toggle" onClick={() => setExpanded(!expanded)}>
28
- {expanded ? t("t.less") : t("t.more")}
36
+ {expanded ? strings?.readLess : strings?.readMore}
29
37
  </span>
30
38
  )
31
39
  }
@@ -38,13 +46,14 @@ const ExpandableText = (props: ExpandableTextProps) => {
38
46
  if (!props.children) return null
39
47
 
40
48
  if (props.children.length > maxLength) {
41
- button = moreLessButton(expanded, setExpanded)
49
+ button = moreLessButton(expanded, setExpanded, props.strings)
42
50
  }
43
51
  return (
44
- <div className={`expandable-text ${props.className}`}>
52
+ <div className={`expandable-text ${props?.className}`}>
53
+ {" "}
45
54
  <Markdown
46
55
  children={getText(props.children, expanded, maxLength)}
47
- options={{ disableParsingRawHTML: true }}
56
+ options={props.markdownProps}
48
57
  />
49
58
  {button}
50
59
  </div>