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" ;
12import { CenteredPage as CenteredPageComponent } from "./centered_page" ;
23import { CommonContextProvider as CommonContextProviderComponent } from "./common_context" ;
34import { DndFileInput as DndFileInputComponent } from "./dnd_file_input" ;
@@ -44,6 +45,7 @@ namespace Components {
4445 export const ErrorFallback = ErrorFallbackComponent ;
4546 export const FallbackImage = FallbackImageComponent ;
4647 export const LinkHandler = LinkHandlerComponent ;
48+ export const AutoTextLinking = AutoTextLinkingComponent ;
4749 export const DndFileInput = DndFileInputComponent ;
4850 export const Fieldset = FieldsetComponent ;
4951
Original file line number Diff line number Diff line change 1+ import * as Common from "@frontend/common" ;
12import { CircularProgress , Stack , Typography } from "@mui/material" ;
23import { ErrorBoundary , Suspense } from "@suspensive/react" ;
34import * as React from "react" ;
@@ -12,7 +13,9 @@ const InnerPatronList: React.FC<{ year: number }> = ErrorBoundary.with(
1213 return data . map ( ( patron ) => (
1314 < Stack key = { patron . name } spacing = { 1 } sx = { { my : 2 } } >
1415 < 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 >
1619 </ Stack >
1720 ) ) ;
1821 } )
You can’t perform that action at this time.
0 commit comments