Skip to content

ThinkR-open/css2r

Repository files navigation

{css2r}

Lifecycle: experimental R-CMD-check

Installation

You can install the development version of {css2r} like so:

remotes::install_github("ThinkR-open/css2r")

Extract CSS properties from a webpage

library(css2r)

thinkr <- css2r$new(url = "https://thinkr.fr")
#> ✔ Internet ok
#> ✔ html page downloaded
#> ✔ CSS links extracted
#> ✔ CSS links filtered
#> ✔ CSS downloaded
#> ✔ Colors extracted successfully
#> ✔ Colors analyzed successfully.
#> ✔ Google Fonts detected and analyzed.
#> ✔ Shiny theme code generated.
#> fluidPage(
#>   theme = bslib::bs_theme(
#>     bg = "#FFFFFF",
#>     fg = "#000000",
#>     primary = "#38404C",
#>     secondary = "#0046C8",
#>     base_font = bslib::font_google("Rubik")
#>   ),
#>   h1("Hello World primary", class = "text-center text-secondary"),
#>   h1("Hello World secondary", class = "text-center text-primary")
#> )

Extract CSS files

thinkr$domain_css_links
#> [1] "https://thinkr.fr/wp-includes/css/dist/block-library/style.min.css?ver=d05679c553c9330ebf77a126f5cbe471"             
#> [2] "https://thinkr.fr/wp-includes/js/mediaelement/mediaelementplayer-legacy.min.css?ver=a0b8817f2ea537894019ee894a03d46f"
#> [3] "https://thinkr.fr/wp-includes/js/mediaelement/wp-mediaelement.min.css?ver=d05679c553c9330ebf77a126f5cbe471"          
#> [4] "https://thinkr.fr/wp-content/plugins/contact-form-7/includes/css/styles.css?ver=56dc953aa6201753571ad248868111e6"    
#> [5] "https://thinkr.fr/wp-content/themes/thinkr/build/styles.min.css?ver=d05679c553c9330ebf77a126f5cbe471"                
#> [6] "https://thinkr.fr/wp-content/plugins/ics-calendar/assets/style.min.css?ver=c4c312147315328d9608fa93e291ea72"

Extract top colors

thinkr$top_colors
#> $white_black
#>      Color Count
#> 10 #000000     3
#> 98 #FFFFFF     1
#> 
#> $top_colors
#>     Color Count
#> 1 #38404C   133
#> 2 #0046C8    72
#> 3 #F05622    40
#> 4 #20B8D6    23

Show shiny theme

cat(thinkr$shiny_code)
#> fluidPage(
#>   theme = bslib::bs_theme(
#>     bg = "#FFFFFF",
#>     fg = "#000000",
#>     primary = "#38404C",
#>     secondary = "#0046C8",
#>     base_font = bslib::font_google("Rubik")
#>   ),
#>   h1("Hello World primary", class = "text-center text-secondary"),
#>   h1("Hello World secondary", class = "text-center text-primary")
#> )

Run the application

You can launch the application by running:

css2r::run_app()

Code of Conduct

Please note that the css2r project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

About

Shiny App to extract CSS from website

Topics

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published