Giter Site home page Giter Site logo

pisyukaev / twitch-sub-goal Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 0.0 1.28 MB

This is a very simple extension to customize your twitch sub/follow goals!

Home Page: https://chrome.google.com/webstore/detail/twitch-sub-goal/heapnplmfdahfoanhpibmpmkkhiignim

License: MIT License

JavaScript 1.29% TypeScript 98.71%
customization extension extension-chrome plasmo subgoals twitch twitch-tv twitchtv typescript

twitch-sub-goal's People

Contributors

crashmax-dev avatar pisyukaev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

twitch-sub-goal's Issues

Function to generate css styles

Я использую вот такую функцию для генерации стилей

export const selectors: Record<string, string> = {
  widget: '.goal_widget',
  progressBar: '.goal_widget__progress_bar',
  image: '.goal_widget__image.tw-image',
  leftText: '.goal_widget__metadata > div:first-child',
  rightText: '.goal_widget__contributions',
  counterText: '.goal_widget__contributions > span'
}

export type WidgetOptions = {
  widget: {
    backgroundColor: string
    borderRadius: string
    borderWidth: string
    borderStyle: string
    borderColor: string
  }
  ...
}

export function transformOptionsToStyles(styles: WidgetOptions) {
  return Object.entries(styles)
    .reduce<string[]>((classes, [selector, styles]) => {
      const classStyles = Object.entries(styles).reduce<string[]>(
        (styles, [property, value]) => {
          styles.push(
            `\n${decamelize(property, {
              separator: '-'
            })}: ${value} !important;`
          )
          return styles
        },
        []
      )
      classes.push(`${selectors[selector]} {${classStyles.join('')}}`)
      return classes
    }, [])
    .join('\n ')
}

и чтобы не плодить лишние поля в настройках (property), пришлось поставить библиотеку https://github.com/sindresorhus/decamelize для трансформации camelCase: backgroundColor -> background-color

Originally posted by @crashmax-dev in #21 (comment)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.