Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Custom class names #32

Open
joepie91 opened this issue Aug 27, 2018 · 3 comments
Open

Feature request: Custom class names #32

joepie91 opened this issue Aug 27, 2018 · 3 comments

Comments

@joepie91
Copy link

It'd be greatly helpful if it were possible to specify custom class names for each component in a FlexLayout layout, instead of just having the default class names like flexlayout__border_button--selected.

Custom class names would make it possible to integrate this library with eg. themeing systems that are based on CSS Modules, without requiring a lot of extra complexity in FlexLayout itself; it'd just have to internally replace the default class names with the specified ones, when they are specified.

What such an API might look like:

var json = {
	global: {
		classNames: {
			button: "layout-button",
			buttonSelected: "layout-button-selected"
			// ...
		}
	},
	borders: [],
	layout: {
		// ....
	}
};

So when somebody is using CSS Modules, it might look like:

var css = require("./style.css");

var json = {
	global: {
		classNames: {
			button: css.layoutButton,
			buttonSelected: css.layoutButtonSelected
			// ...
		}
	},
	borders: [],
	layout: {
		// ....
	}
};

... and they'd get completely locally-scoped styles.

@nealus
Copy link
Collaborator

nealus commented Oct 3, 2018

I've added a new layout property:
classNameMapper?: (defaultClassName: string) => string
in the latest source.
I think this should handle your use case, please can you take a look and comment

@joepie91
Copy link
Author

joepie91 commented Oct 3, 2018

Functionality-wise, that looks exactly right. Thanks!

One useful addition would be a list of all the class names in the documentation and what they are for, so that users can know which class names to account for in their mapper.

Currently, this can already be figured out from the source code, but having a canonical list of them would be useful both for easier development and for more easily tracking changed class names across FlexLayout versions (in cases where they're changed).

@Aiso786
Copy link

Aiso786 commented Oct 5, 2018

Hello @nealus, that looks really great. When are you making another release to include this new feature ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants