Gets theme configuration and renders theme css into fragment
430060
def include_theme_files(self, fragment):
        
        theme = self.get_theme()
        if not theme or 'package' not in theme:
            return

        theme_package, theme_files = theme.get('package', None), theme.get('locations', [])
        resource_loader = ResourceLoader(theme_package)
        for theme_file in theme_files:
            fragment.add_css(resource_loader.load_unicode(theme_file))
1031499
def render(view_options=configuration)
      logger.debug "rendering"
      result = ""
      if template
        logger.debug "rendering with template : #{template}"
        view = AppView.new(items, view_options)
        view.template = template
        result = view.render
      else
        items.each_with_index do |item, index|
          result += "\n" unless index == 0
          result += item.name.green + ":\n"
          if item.respond_to?(:attributes)
            attributes = item.attributes.deep_clone
            result += attributes.recursively_stringify_keys!.to_conf.gsub(/\s+$/, '') # strip trailing whitespace from YAML
            result += "\n"
          end
        end
      end
      result
    end
1101432
function stylesheet(config = {}) {
	const minifier = new cleancss();
	const styles = [];

	return {
		name: 'stylesheet',
		transform(code, id) {
			// Note that 'id' can be mapped to a CJS proxy import, in which case
			// 'id' will start with 'commonjs-proxy', so let's first check if we
			// are importing an existing css file (i.e. startsWith()).
			if (!id.startsWith(path.resolve('.')) || !id.endsWith('.css')) {
				return;
			}

			if (config.minify) {
				code = minifier.minify(code).styles;
			}

			// keep track of all imported stylesheets (already minified)
			styles.push(code);

			return {
				code: 'export default ' + JSON.stringify(code)
			};
		},
		generateBundle(opts, bundle) {
			if (!config.extract) {
				return;
			}

			const entry = Object.keys(bundle).find(v => bundle[v].isEntry);
			const name = (entry || '').replace(/\.js$/i, '.css');
			if (!name) {
				this.error('failed to guess the output file name');
			}

			bundle[name] = {
				code: styles.filter(v => !!v).join('')
			};
		}
	};
}
866923
function withTheme(WrappedComponent) {
  const displayName =
    WrappedComponent.displayName || WrappedComponent.name || 'Component'

  return class extends React.Component {
    static displayName = `withTheme(${displayName})`

    render() {
      return (
        <ThemeConsumer>
          {theme => <WrappedComponent theme={theme} {...this.props} />}
        </ThemeConsumer>
      )
    }
  }
}
428055
function populateThemes(){
		this.preferences.getTheme(function(themeStyles) {
			var selectElement = document.getElementById('editorTheme');//$NON-NLS-0$
			while (selectElement.hasChildNodes() ){
				selectElement.removeChild(selectElement.lastChild);
			}
			for (var i =0; i < themeStyles.styles.length; i++) {
				var option = document.createElement('option');
				option.setAttribute('value', themeStyles.styles[i].name);
				//checks if a theme is the current theme 
				if (themeStyles.styles[i].name === themeStyles.style.name){
					option.setAttribute('selected', 'true');
				}
				option.appendChild(document.createTextNode(themeStyles.styles[i].name));
				selectElement.appendChild(option);
			}
			this.selectTheme(themeStyles.style.name);
		}.bind(this));
	}
983066
def render(pieces, style):
    """"""
    if pieces["error"]:
        return {"version": "unknown",
                "full-revisionid": pieces.get("long"),
                "dirty": None,
                "error": pieces["error"],
                "date": None}

    if not style or style == "default":
        style = "pep440"  # the default

    if style == "pep440":
        rendered = render_pep440(pieces)
    elif style == "pep440-pre":
        rendered = render_pep440_pre(pieces)
    elif style == "pep440-post":
        rendered = render_pep440_post(pieces)
    elif style == "pep440-old":
        rendered = render_pep440_old(pieces)
    elif style == "pep440-branch-based":
        rendered = render_pep440_branch_based(pieces)
    elif style == "git-describe":
        rendered = render_git_describe(pieces)
    elif style == "git-describe-long":
        rendered = render_git_describe_long(pieces)
    else:
        raise ValueError("unknown style '%s'" % style)

    return {"version": rendered, "full-revisionid": pieces["long"],
            "dirty": pieces["dirty"], "error": None,
            "date": pieces.get("date")}
1019704
function(options) {
    options.resources = {
        css: [],
        js: []
    };
    // - copy template css file
    options.resources.css.push(fileResolver(
        options,
        require.resolve('./resources/docco-template.css')
    ));
    // - copy jquery js file
    options.resources.js.push(fileResolver(
        options,
        require.resolve('jquery/dist/jquery.min.js')
    ));
    // - copy jstree distribution js
    options.resources.js.push(fileResolver(
        options,
        require.resolve('jstree/dist/jstree.js')
    ));
    // - copy jstree search plugin js
    options.resources.js.push(fileResolver(
        options,
        require.resolve('jstree/src/jstree.search.js')
    ));
    // - copy jstree distribution css
    options.resources.css.push(fileResolver(
        options,
        require.resolve('jstree/dist/themes/default-dark/style.min.css')
    ));
    // - copy jstree distribution images
    options.resources.css.push(fileResolver(
        options,
        require.resolve('jstree/dist/themes/default-dark/32px.png'),
        '32px.png'
    ));
    options.resources.css.push(fileResolver(
        options,
        require.resolve('jstree/dist/themes/default-dark/40px.png'),
        '40px.png'
    ));
    options.resources.css.push(fileResolver(
        options,
        require.resolve('jstree/dist/themes/default-dark/throbber.gif'),
        'throbber.gif'
    ));
    // - copy bootstrap js file
    options.resources.js.push(fileResolver(
        options,
        require.resolve('./resources/bootstrap.js')
    ));
    // - copy highlightjs style
    options.resources.css.push(fileResolver(
        options,
        require.resolve('highlight.js/styles/' + options.highlightStyle + '.css')
    ));
    // - copy markdown style
    options.resources.css.push(fileResolver(
        options,
        require.resolve('./resources/gfm.css')
    ));
    // -copy config.css
    if (options.css) {
        options.resources.css.push(fileResolver(
            options,
            options.css
        ));
    }
    return options;
}
1220813
function themeBuildStream() {
  // Make a copy so that we don't modify the actual config that is used by other functions
  var paths = config.themeBaseFiles.slice(0);
  config.componentPaths.forEach(component => paths.push(path.join(component, '*-theme.scss')));
  paths.push(config.themeCore);

  return gulp.src(paths)
  .pipe(concat('default-theme.scss'))
  .pipe(utils.hoistScssVariables())
  .pipe(sass())
  .pipe(dedupeCss())
  // The PostCSS orderedValues plugin modifies the theme color expressions.
  .pipe(minifyCss({orderedValues: false}))
  .pipe(utils.cssToNgConstant('material.core', '$MD_THEME_CSS'));
}
1261637
function renderHtml(fragment, opts) {
    var html = (!fragment || !u.trim(fragment._txt)) ?
      '&nbsp;' : // show space for empty/missing to allow selection/editing
      renderMarkdown(fragment._txt, opts);
    // use opts.noWrap to avoid breaking CSS nested selectors like li > ul in menus
    if (opts && opts.noWrap) return html;
    var href = (fragment && esc(fragment._href)) || '';
    return '<div data-render-html="' + href + '">' + html + '</div>';
  }
1081409
public function getThemesConfig()
    {
        if (empty($this->config['Rcm'])
            || empty($this->config['Rcm']['themes'])
        ) {
            throw new RuntimeException(
                'No Themes found defined in configuration.  Please report the issue
                 with the themes author.'
            );
        }

        return $this->config['Rcm']['themes'];
    }
616374
public function render() {
		?>
		<div class="wrap">
			<h1><?php echo wp_get_theme(); ?> <?php _e( 'Theme Options', 'pressbooks' ); ?></h1>
			<?php settings_errors(); ?>
			<?php $active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'global'; ?>
			<h2 class="nav-tab-wrapper">
				<?php foreach ( $this->getTabs() as $slug => $subclass ) { ?>
					<a href="<?php echo admin_url( '/themes.php' ); ?>?page=pressbooks_theme_options&tab=<?php echo $slug; ?>"
						class="nav-tab <?php echo $active_tab === $slug ? 'nav-tab-active' : ''; ?>"><?php echo $subclass::getTitle(); ?></a>
				<?php } ?>
			</h2>
			<form method="post" action="options.php">
				<?php
				do_action( 'pb_before_themeoptions_settings_fields' );
				settings_fields( 'pressbooks_theme_options_' . $active_tab );
				do_settings_sections( 'pressbooks_theme_options_' . $active_tab );
				submit_button();
				?>
			</form>
		</div>
		<?php
	}
667699
def get_template_context(src, container="div", classes="", inner_classes="", alt="", background_image=False, no_css=False, aria_hidden=False):
    """"""
    context = {
        "container": container,
        "classes": classes,
        "aspect_padding_bottom": aspect_ratio_percent(src),
        "alt": alt,
        "background_image": background_image,
        "no_css": no_css,
        "inner_classes": inner_classes,
        "aria_hidden": aria_hidden,
    }

    # We can't do any of the srcset (or JS switching fallback) if we don't
    # have a thumbnail library installed.
    if not get_thumbnail_engine():
        context["image"] = src
        return context

    sizes = get_image_sizes(src)
    context["image_sizes"] = sizes

    # Set the first image in the list as the one to be rendered initially
    # (pre-JS-fallback). `if sizes` might not be a necessary check...
    context["image"] = sizes[0]

    context["image_sizes_json"] = json.dumps(sizes)
    srcset_items = ["{} {}w".format(size["url"], size["width"]) for size in sizes]

    context["image_sizes_srcset"] = ", ".join(srcset_items)
    return context
344145
function convertRawTheme(theme) {
  if (!Array.isArray(theme.constants)) {
    return {
      constants: Object.keys(theme.constants).map(key => theme.constants[key]),
      styles: [].concat(theme.styles),
      animations: [].concat(theme.animations)
    }
  }
  else
    return theme;
}
665626
public function prepareTheme()
    {
        $this->viewBuilder()->layout('default');
        if (!empty($this->request->params['prefix']) &&
            strtolower($this->request->params['prefix']) === 'admin'
        ) {
            $this->viewBuilder()->theme(option('back_theme'));
        } else {
            $this->viewBuilder()->theme(option('front_theme'));
        }

        if ($this->request->isAjax()) {
            $this->viewBuilder()->layout('ajax');
        }

        if ($this->request->isHome()) {
            $this->viewBuilder()->layout('home');
        }

        if ($this->request->isDashboard()) {
            $this->viewBuilder()->layout('dashboard');
        }
    }
1058072
function generateTheme({
  stylesDir,
  mainLessFile,
  varFile,
  outputFilePath,
  themeVariables
}) {
  return new Promise((resolve, reject) => {
    /*
      You own custom styles (Change according to your project structure)
      
      - stylesDir - styles directory containing all less files
      - varFile - variable file containing your custom variables
      - mainLessFile - less main file which imports all styles
    */
    let content = '';
    // const hashCode = hash.sha256().update(content).digest('hex');
    // if(hashCode === hashCache){
    //   resolve(cssCache);
    //   return;
    // }
    // hashCache = hashCode;
    let themeCompiledVars = {};
    let themeVars = themeVariables || [];
    const lessPaths = [
      stylesDir
    ];

    return bundle({
      src: varFile
    })
      .then(colorsLess => {
        const mappings = Object.assign(generateColorMap(colorsLess), mainLessFile? generateColorMap(mainLessFile): {});
        return [mappings, colorsLess];
      })
      .then(([mappings, colorsLess]) => {
        let css = "";
        /*
         If not pass in themeVariables, the variables in varFile will be used
         */
        if (!themeVariables) {
            let varJs = lessToJs(fs.readFileSync(varFile, 'utf8'));
            themeVars.forEach(varName => {
                delete varJs[varName];
            });
            themeVars.push(...Object.keys(varJs));
        }
        if (!themeVars.length) {
            themeVars.push("@theme-color");
        }
        themeVars = themeVars.filter(name => name in mappings);
        themeVars.forEach(varName => {
          const color = mappings[varName];
          css = `.${varName.replace("@", "")} { color: ${color}; }\n ${css}`;
        });

        css = `${colorsLess}\n${css}`;
        return render(css, lessPaths).then(({ css }) => [
          css,
          mappings,
          colorsLess
        ]);
      })
      .then(([css, mappings, colorsLess]) => {
        css = css.replace(/(\/.*\/)/g, "");
        const regex = /.(?=\S*['-])([.a-zA-Z0-9'-]+)\ {\n\ \ color:\ (.*);/g;
        themeCompiledVars = getMatches(css, regex);
        content = `${content}\n${colorsLess}`;
        return render(content, lessPaths).then(({ css }) => {
          return getCssModulesStyles(stylesDir).then(customCss => {
            return [
              `${customCss}\n${css}`,
              mappings,
              colorsLess
            ];
          })
          
        });
      })
      .then(([css, mappings, colorsLess]) => {
        return postcss([reducePlugin(themeCompiledVars)])
          .process(css, {
            parser: less.parser,
            from: mainLessFile | varFile
          })
          .then(({ css }) => [css, mappings, colorsLess]);
      })
      .then(([css, mappings, colorsLess]) => {
        Object.keys(themeCompiledVars).forEach(varName => {
          let color;
          if (/(.*)-(\d)/.test(varName)) {
            color = themeCompiledVars[varName];
            varName = getShade(varName);
          } else {
            color = themeCompiledVars[varName];
          }
          color = color.replace('(', '\\(').replace(')', '\\)');
          css = css.replace(new RegExp(`${color}`, "g"), varName);
        });

        css = `${colorsLess}\n${css}`;

        themeVars.reverse().forEach(varName => {
          css = css.replace(new RegExp(`${varName}(\ *):(.*);`, 'g'), '');
          css = `${varName}: ${mappings[varName]};\n${css}\n`;
        });
        css = css.replace(/\n+/g, '\n');

        css = uniqueCss(css);

        if (outputFilePath) {
          fs.writeFileSync(outputFilePath, css);
          console.log(
            `Theme generated successfully. OutputFile: ${outputFilePath}`
          );
        } else {
          console.log(`Theme generated successfully`);
        }
        cssCache = css;
        return resolve(css);
      })
      .catch(err => {
        console.log("Error", err);
        reject(err);
      });
  });
}
464726
function MyComponent() {
  const theme = useTheme();
  const width =
    [...theme.breakpoints.keys].reverse().reduce((output, key) => {
      // eslint-disable-next-line react-hooks/rules-of-hooks
      const matches = useMediaQuery(theme.breakpoints.only(key));

      return !output && matches ? key : output;
    }, null) || 'xs';

  return <span>{`width: ${width}`}</span>;
}
489111
def compile_theme(theme_id=None):
    """"""
    from engineer.processors import convert_less
    from engineer.themes import ThemeManager

    if theme_id is None:
        themes = ThemeManager.themes().values()
    else:
        themes = [ThemeManager.theme(theme_id)]

    with(indent(2)):
        puts(colored.yellow("Compiling %s themes." % len(themes)))

        for theme in themes:
            theme_output_path = (theme.static_root / ('stylesheets/%s_precompiled.css' % theme.id)).normpath()

            puts(colored.cyan("Compiling theme %s to %s" % (theme.id, theme_output_path)))
            with indent(4):
                puts("Compiling...")
                convert_less(theme.static_root / ('stylesheets/%s.less' % theme.id),
                             theme_output_path,
                             minify=True)
                puts(colored.green("Done.", bold=True))