File tree Expand file tree Collapse file tree 3 files changed +19
-1
lines changed
shop/src/components/features Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change
1
+ import * as React from "react" ;
2
+
3
+ import { LinkHandler } from "./link_handler" ;
4
+
5
+ const urlRegex = / ( m a i l t o : [ \w . - ] + @ [ \w . - ] + \. [ a - z A - Z ] { 2 , } ) | ( h t t p s ? : \/ \/ [ ^ \s ] + ) / gi;
6
+
7
+ export const AutoTextLinking : React . FC < { children : string } > = ( { children } ) => {
8
+ const convertedChildren = children
9
+ . split ( urlRegex )
10
+ . filter ( ( text ) => text !== undefined )
11
+ . map ( ( text ) => ( text . match ( urlRegex ) ? < LinkHandler href = { text } children = { text } /> : text ) ) ;
12
+ return < span children = { convertedChildren } /> ;
13
+ } ;
Original file line number Diff line number Diff line change
1
+ import { AutoTextLinking as AutoTextLinkingComponent } from "./auto_text_linking" ;
1
2
import { CenteredPage as CenteredPageComponent } from "./centered_page" ;
2
3
import { CommonContextProvider as CommonContextProviderComponent } from "./common_context" ;
3
4
import { DndFileInput as DndFileInputComponent } from "./dnd_file_input" ;
@@ -44,6 +45,7 @@ namespace Components {
44
45
export const ErrorFallback = ErrorFallbackComponent ;
45
46
export const FallbackImage = FallbackImageComponent ;
46
47
export const LinkHandler = LinkHandlerComponent ;
48
+ export const AutoTextLinking = AutoTextLinkingComponent ;
47
49
export const DndFileInput = DndFileInputComponent ;
48
50
export const Fieldset = FieldsetComponent ;
49
51
Original file line number Diff line number Diff line change
1
+ import * as Common from "@frontend/common" ;
1
2
import { CircularProgress , Stack , Typography } from "@mui/material" ;
2
3
import { ErrorBoundary , Suspense } from "@suspensive/react" ;
3
4
import * as React from "react" ;
@@ -12,7 +13,9 @@ const InnerPatronList: React.FC<{ year: number }> = ErrorBoundary.with(
12
13
return data . map ( ( patron ) => (
13
14
< Stack key = { patron . name } spacing = { 1 } sx = { { my : 2 } } >
14
15
< Typography variant = "h5" sx = { ( theme ) => ( { fontWeight : 400 , color : theme . palette . primary . dark } ) } children = { patron . name } />
15
- < Typography variant = "subtitle1" children = { patron . contribution_message || "Weave with Python!" } />
16
+ < Typography variant = "subtitle1" sx = { ( theme ) => ( { a : { color : theme . palette . primary . main } , whiteSpace : "pre-wrap" } ) } >
17
+ < Common . Components . AutoTextLinking children = { patron . contribution_message . replace ( "\\n" , "\n" ) || "Weave with Python!" } />
18
+ </ Typography >
16
19
</ Stack >
17
20
) ) ;
18
21
} )
You can’t perform that action at this time.
0 commit comments