question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CSS modules theme example

See original GitHub issue

Hello,

I love this project, it is working great so far.

Just a suggestion on a docs improvement. I like how you can theme it using CSS modules or inline styles etc, but there is no good CSS modules example.

I just converted the basic styles over to a CSS (not a big thing) but think it would be great if you provided a basic example using CSS modules.

Here is the CSS that I converted from https://codepen.io/moroshko/pen/OpPqxY

.container {
  position: relative;
}

.input {
  width: 240px;
  height: 30px;
  padding: 10px 20px;
  font-family: Helvetica, sans-serif;
  font-weight: 300;
  font-size: 16px;
  border: 1px solid #aaa;
  border-radius: 4px;
}

.inputFocused {
  outline: none;
}

.inputOpen {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.suggestionsContainer {
  display: none;
}

.suggestionsContainerOpen {
  display: block;
  position: absolute;
  top: 51px;
  width: 280px;
  border: 1px solid #aaa;
  background-color: #fff;
  font-family: Helvetica, sans-serif;
  font-weight: 300;
  font-size: 16px;
  border-radius: 0 0 4px 4px;
  z-index: 2;
}

.suggestionsList {
  margin: 0;
  padding: 0;
  list-style-type: none;
}

.suggestion {
  cursor: pointer;
  padding: 10px 20px;
}

.suggestionHighlighted {
  background-color: #ddd;
}

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:7
  • Comments:5

github_iconTop GitHub Comments

4reactions
akhayooncommented, Feb 13, 2018

I had to do this to get it working

        .react-autosuggest__container 
        {
            position: relative;
        }
          
        .react-autosuggest__input 
        {
            width:          100%;
            height:         36px;
            padding:        10px;
            border:         1px solid $chefhero-light-green;
            border-radius:  4px;
            border-bottom-right-radius: 0;
            border-top-right-radius: 0;
        }
          
        .react-autosuggest__input--focused 
        {
            outline: none;
        }
          
        .react-autosuggest__input--open 
        {
            border-bottom-left-radius:  0;
            border-bottom-right-radius: 0;
        }
          
        .react-autosuggest__suggestions-container
        {
            display: none;
        }
          
        .react-autosuggest__suggestions-container--open 
        {
            display:            block;
            position:           absolute;
            top:                33px;
            width:              100%;
            min-width:          160px;
            margin-left:        1px;
            background-color: #FFFFFF;
            border-radius:      0 0 4px 4px;
            z-index:            2;
            box-shadow:         0 6px 12px rgba(0, 0, 0, 0.175);
		    background-clip:    padding-box;
        }
          
        .react-autosuggest__suggestions-list 
        {
            margin:             0;
            padding:            0;
            list-style-type:    none;
        }
        
        .react-autosuggest__suggestion 
        {
            cursor:     pointer;
            padding:    10px 20px;
        }
        
        .react-autosuggest__suggestion--highlighted 
        {
            background-color: $chefhero-hover-green;
        }
1reaction
sturtevantcommented, Jul 23, 2020

I had to name the theme.css file in the example provided by @stewartduffy as <something>.module.css in order to get it working. I think it has something to do with the react-scripts preprocessing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

klimashkin/css-modules-theme: Theme composition ... - GitHub
A CSS Module is just a CSS file in which all class names and animation names are transformed on build time to be...
Read more >
Themify your (S)CSS Modules | Technology - Lastminute.com
Personalise your application with shiny themes combining CSS Modules and Bootstrap SASS.
Read more >
CSS modules | Barbarian Meets Coding
CSS modules are a CSS framework that allows you to write CSS classes and animations that are locally scoped by default and thus...
Read more >
change-theme-with-css-modules - CodeSandbox
CodeSandbox is an online editor tailored for web applications.
Read more >
A simple React Theme Component using CSS variables
We like to use CSS Modules so the solution should be compatible. ... For example, a small Button component could look like this: ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found