2021-05-19 00:05:20 +00:00
import React , { useMemo , useState } from "react"
2021-05-15 16:05:13 +00:00
import Style from "./PageRepository.module.css"
import classNames from "classnames"
2021-05-18 17:15:53 +00:00
import BoxRepositoryTweets from "../components/interactive/BoxRepositoryTweets"
2021-05-18 17:37:32 +00:00
import BoxWordcloud from "../components/interactive/BoxWordcloud"
2021-05-19 00:05:20 +00:00
import ButtonIconOnly from "../components/base/ButtonIconOnly"
import { faAt , faChartBar , faClock , faCloud , faHashtag , faMap , faMapPin } from "@fortawesome/free-solid-svg-icons"
import BoxFull from "../components/base/BoxFull"
import BoxHeader from "../components/base/BoxHeader"
import PickerVisualization from "../components/interactive/PickerVisualization"
import PickerFilter from "../components/interactive/PickerFilter"
2021-05-15 16:05:13 +00:00
export default function PageRepository ( { className , ... props } ) {
2021-05-19 00:05:20 +00:00
const [ visualizationTab , setVisualizationTab ] = useState ( "wordcloud" )
const [ addFilterTab , setAddFilterTab ] = useState ( "hashtag" )
2021-05-18 17:37:32 +00:00
const tweets = [
{
"conditions" : [ ] ,
"content" : "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec posuere lacinia eleifend. Maecenas a neque augue. Nulla dapibus lobortis gravida. Quisque quis ultricies elit. Donec in tortor augue. Cras eget aliquam felis. Nunc tempor, ipsum in lobortis tristique, nunc ante velit." ,
"insert_time" : "2021-05-18T18:56Z" ,
"location" : null ,
"place" : "Casa mia" ,
"poster" : "USteffo" ,
"snowflake" : "1394698342282809344" ,
} ,
]
2021-05-19 00:05:20 +00:00
const words = useMemo (
( ) => {
let preprocessedWords = { }
for ( const tweet of tweets ) {
if ( ! tweet . content ) {
continue
}
for ( const word of tweet . content . toLowerCase ( ) . split ( /\s+/ ) ) {
if ( ! preprocessedWords . hasOwnProperty ( word ) ) {
preprocessedWords [ word ] = 0
}
preprocessedWords [ word ] += 1
}
}
let processedWords = [ ]
for ( const word in preprocessedWords ) {
if ( ! preprocessedWords . hasOwnProperty ( word ) ) {
continue
}
processedWords . push ( {
text : word ,
value : preprocessedWords [ word ]
} )
2021-05-18 17:37:32 +00:00
}
2021-05-19 00:05:20 +00:00
return processedWords
} ,
[ tweets ]
)
2021-05-18 17:37:32 +00:00
2021-05-15 16:05:13 +00:00
return (
< div className = { classNames ( Style . PageRepository , className ) } { ... props } >
2021-05-19 00:05:20 +00:00
< BoxHeader className = { Style . Header } >
Repository Senza Nome
< / B o x H e a d e r >
< BoxRepositoryTweets
className = { Style . Tweets }
tweets = { tweets }
/ >
< PickerVisualization
className = { Style . VisualizationPicker }
currentTab = { visualizationTab }
setTab = { setVisualizationTab }
/ >
{ visualizationTab === "wordcloud" ?
< BoxWordcloud
className = { Style . Wordcloud }
words = { words }
/ >
: null }
< PickerFilter
className = { Style . FilterPicker }
currentTab = { addFilterTab }
setTab = { setAddFilterTab }
/ >
2021-05-15 16:05:13 +00:00
< / d i v >
)
}