@heliosgraphics/ui 2.0.1-alpha.3 → 2.0.1-alpha.5

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/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Helios Graphics
3
+ Copyright (c) 2016 Helios Graphics
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -5,7 +5,9 @@
5
5
  user-select: none;
6
6
  }
7
7
 
8
- .dropdownOpen [data-ui-component="Icon"] {
8
+ .dropdownOpen .dropdown__activator [data-ui-icon="caret-down"],
9
+ .dropdownOpen .dropdown__activator [data-ui-icon="arrow-down"],
10
+ .dropdownOpen .dropdown__activator [data-ui-icon="chevron-down"] {
9
11
  transition: transform 96ms ease-in-out;
10
12
  transform: rotate(180deg);
11
13
  }
@@ -53,40 +55,19 @@
53
55
  position: absolute;
54
56
  z-index: var(--z-index-8);
55
57
 
56
- display: none;
57
58
  min-width: 240px;
58
59
  opacity: 0;
59
60
 
60
61
  transition:
61
- display 96ms ease-in-out allow-discrete,
62
62
  transform 96ms ease-in-out,
63
63
  opacity 96ms ease-in-out;
64
64
  pointer-events: none;
65
65
  }
66
66
 
67
- .dropdown__navActive {
68
- display: block;
69
- opacity: 1;
67
+ .dropdown__nav.dropdown__navActive {
68
+ opacity: 1 !important;
70
69
 
71
- transform: translateY(0);
70
+ transform: translateY(0) !important;
72
71
 
73
72
  pointer-events: all;
74
-
75
- @starting-style {
76
- opacity: 0;
77
- }
78
- }
79
-
80
- .dropdownBottomLeft .dropdown__navActive,
81
- .dropdownBottomRight .dropdown__navActive {
82
- @starting-style {
83
- transform: translateY(-6px);
84
- }
85
- }
86
-
87
- .dropdownTopLeft .dropdown__navActive,
88
- .dropdownTopRight .dropdown__navActive {
89
- @starting-style {
90
- transform: translateY(6px);
91
- }
92
73
  }
@@ -95,6 +95,7 @@ export const Dropdown: FC<DropdownProps> = ({ children, items, isDisabled, posit
95
95
  <div
96
96
  role="button"
97
97
  tabIndex={0}
98
+ className={styles.dropdown__activator}
98
99
  onClick={onSetVisible}
99
100
  onKeyDown={onKeyDown}
100
101
  aria-expanded={isVisible}
@@ -1,4 +1,4 @@
1
- import { getTypographyUtility } from "../Text/Text.utils"
1
+ import { getTypographyUtility, stripTypographyProps } from "../Text/Text.utils"
2
2
  import { getClasses } from "@heliosgraphics/utils"
3
3
  import { H0 } from "./components/H0"
4
4
  import { H1 } from "./components/H1"
@@ -9,7 +9,7 @@ import { H5 } from "./components/H5"
9
9
  import { H6 } from "./components/H6"
10
10
  import styles from "./Heading.module.css"
11
11
  import type { HeadingProps } from "./Heading.types"
12
- import type { FC, CSSProperties } from "react"
12
+ import type { FC, CSSProperties, HTMLAttributes } from "react"
13
13
 
14
14
  export const Heading: FC<HeadingProps> = (props) => {
15
15
  const { level, lineClamp, lineHeight, style, className, ...rest } = props
@@ -19,10 +19,7 @@ export const Heading: FC<HeadingProps> = (props) => {
19
19
  [styles.headingSecondary]: props.emphasis === "secondary",
20
20
  [styles.headingTertiary]: props.emphasis === "tertiary",
21
21
  })
22
- const utility: string = getTypographyUtility({
23
- ...props,
24
- className: headingClasses,
25
- })
22
+ const utility: string = getTypographyUtility(props, headingClasses)
26
23
  const lineClampStyle: CSSProperties | undefined = lineClamp
27
24
  ? {
28
25
  display: "-webkit-box",
@@ -38,9 +35,11 @@ export const Heading: FC<HeadingProps> = (props) => {
38
35
  style || lineClampStyle || lineHeightStyle
39
36
  ? { ...(style || {}), ...(lineClampStyle || {}), ...(lineHeightStyle || {}) }
40
37
  : undefined
38
+ const safeHeadingProps: Omit<HeadingProps, "level" | "lineClamp" | "lineHeight" | "className" | "style"> =
39
+ stripTypographyProps(rest)
41
40
 
42
- const allProps: Omit<HeadingProps, "level"> = {
43
- ...rest,
41
+ const allProps: HTMLAttributes<HTMLHeadingElement> = {
42
+ ...safeHeadingProps,
44
43
  children: props.children,
45
44
  style: mergedStyle,
46
45
  className: utility,
@@ -24,6 +24,7 @@ export const Icon: FC<IconProps> = ({ icon, className, emphasis, size }) => {
24
24
  style={iconSizeStyle}
25
25
  aria-hidden={true}
26
26
  data-ui-component="Icon"
27
+ data-ui-icon={icon}
27
28
  dangerouslySetInnerHTML={{ __html: icons[icon] || "" }}
28
29
  />
29
30
  )
@@ -17,10 +17,7 @@ export const Text: FC<TextProps> = (props) => {
17
17
  [styles.textInherit]: props.emphasis === "inherit",
18
18
  })
19
19
 
20
- const utility: string = getTypographyUtility({
21
- ...props,
22
- className: textClasses,
23
- })
20
+ const utility: string = getTypographyUtility(props, textClasses)
24
21
  const lineClampStyle: object | undefined = props.lineClamp
25
22
  ? {
26
23
  display: "-webkit-box",
@@ -1,7 +1,54 @@
1
- import type { TextProps } from "./Text.types"
1
+ import type { TextBaseProps, TextProps } from "./Text.types"
2
2
  import type { HeadingProps } from "../Heading/Heading.types"
3
3
 
4
- export const _getFontWeight = (fw: TextProps["fontWeight"]): string => {
4
+ export interface TypographyUtilityInput {
5
+ emphasis?: TextBaseProps["emphasis"] | undefined
6
+ fontFamily?: TextBaseProps["fontFamily"] | undefined
7
+ fontStyle?: TextBaseProps["fontStyle"] | undefined
8
+ fontWeight?: TextBaseProps["fontWeight"] | undefined
9
+ isBalanced?: TextBaseProps["isBalanced"] | undefined
10
+ isEllipsis?: TextBaseProps["isEllipsis"] | undefined
11
+ isNonSelectable?: TextBaseProps["isNonSelectable"] | undefined
12
+ textAlign?: TextBaseProps["textAlign"] | undefined
13
+ textDecoration?: TextBaseProps["textDecoration"] | undefined
14
+ whiteSpace?: TextBaseProps["whiteSpace"] | undefined
15
+ wordWrap?: TextBaseProps["wordWrap"] | undefined
16
+ }
17
+
18
+ export const stripTypographyProps = <T extends TypographyUtilityInput>(
19
+ props: T,
20
+ ): Omit<T, keyof TypographyUtilityInput> => {
21
+ const {
22
+ emphasis,
23
+ fontFamily,
24
+ fontStyle,
25
+ fontWeight,
26
+ isBalanced,
27
+ isEllipsis,
28
+ isNonSelectable,
29
+ textAlign,
30
+ textDecoration,
31
+ whiteSpace,
32
+ wordWrap,
33
+ ...rest
34
+ } = props
35
+
36
+ void emphasis
37
+ void fontFamily
38
+ void fontStyle
39
+ void fontWeight
40
+ void isBalanced
41
+ void isEllipsis
42
+ void isNonSelectable
43
+ void textAlign
44
+ void textDecoration
45
+ void whiteSpace
46
+ void wordWrap
47
+
48
+ return rest
49
+ }
50
+
51
+ export const _getFontWeight = (fw: TextBaseProps["fontWeight"]): string => {
5
52
  switch (fw) {
6
53
  case "thin":
7
54
  return "fw-thin"
@@ -27,7 +74,10 @@ export const _getFontWeight = (fw: TextProps["fontWeight"]): string => {
27
74
  }
28
75
  }
29
76
 
30
- export const getTypographyUtility = (props: TextProps | HeadingProps): string => {
77
+ export const getTypographyUtility = (
78
+ props: TextProps | HeadingProps | TypographyUtilityInput,
79
+ className?: string,
80
+ ): string => {
31
81
  const typoClasses: Array<string> = []
32
82
 
33
83
  const fontFamily = props.fontFamily ? props.fontFamily : "sans"
@@ -36,7 +86,7 @@ export const getTypographyUtility = (props: TextProps | HeadingProps): string =>
36
86
  typoClasses.push(fontFamily)
37
87
  typoClasses.push(fontWeight)
38
88
 
39
- if (props.className) typoClasses.push(props.className)
89
+ if (className) typoClasses.push(className)
40
90
  if (props.fontStyle) typoClasses.push(props.fontStyle)
41
91
  if (props.isBalanced) typoClasses.push("text-balanced")
42
92
  if (props.isEllipsis) typoClasses.push("ellipsis")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heliosgraphics/ui",
3
- "version": "2.0.1-alpha.3",
3
+ "version": "2.0.1-alpha.5",
4
4
  "type": "module",
5
5
  "sideEffects": [
6
6
  "*.css",
@@ -1,5 +1,5 @@
1
1
  import { it, describe, expect } from "bun:test"
2
- import { renderMarkdown } from "./Markdown.utils"
2
+ import { renderMarkdown } from "./markdown"
3
3
 
4
4
  describe("markdown", () => {
5
5
  describe("renderMarkdown", () => {