File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
apps/developer-hub/src/components/TruncateToMiddle Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ @use " @pythnetwork/component-library/theme" ;
2
+
3
+ .truncateToMiddle {
4
+ & ::before , & ::after {
5
+ display : inline-block ;
6
+ overflow : hidden ;
7
+ white-space : pre ;
8
+ max-width : 50% ;
9
+ }
10
+
11
+ & ::before {
12
+ content : attr (data-text-start );
13
+ text-overflow : ellipsis ;
14
+ }
15
+
16
+ & ::after {
17
+ content : attr (data-text-end );
18
+ text-overflow : clip ;
19
+ direction : rtl ;
20
+ }
21
+ }
Original file line number Diff line number Diff line change
1
+ import styles from "./index.module.scss" ;
2
+
3
+ export type Props = {
4
+ text : string
5
+ }
6
+
7
+ const TruncateToMiddle = ( { text} : Props ) => {
8
+ return < span className = { styles . truncateToMiddle } data-text-start = { text . slice ( 0 , Math . floor ( text . length / 2 ) ) } data-text-end = { text . slice ( Math . floor ( text . length / 2 ) * - 1 ) } />
9
+ }
10
+
11
+ export default TruncateToMiddle
You can’t perform that action at this time.
0 commit comments