newsdev / ai2html

A script for Adobe Illustrator that converts your Illustrator artwork into an html page.
http://ai2html.org
Other
898 stars 146 forks source link

Namespace problematic when using multiple ai2html exports on one page #69

Open briantjacobs opened 7 years ago

briantjacobs commented 7 years ago

For classes like g-aiAbs or g-aiImg, as in, classes without the project_name, there's a danger that they'll collide with other ai2html exports on same page if the css is modified after the fact. It would be helpful if every class were fully namespaced with project_name, so each export can be self contained without danger of namespace collision.

html[1] += "\t\t\t."+nameSpace+"aiImg{\r";

to

html[1] += "\t\t\t."+nameSpace + makeKeyword(docSettings.project_name)+"aiImg{\r";

Alternatively, add a parent selector to the less specific classes

#g-project_name-box .g-aiAbs{
    position:absolute;
}
mbloch commented 7 years ago

Hi Brian,

This seems reasonable. I have one question -- is there a reason why you would want to redefine a simple style like .g-aiAbs by editing the CSS generated by ai2html? Wouldn't it be preferable to override a style in a particular document by applying the pattern in your second alternative, for example:

#g-project_name-box .g-aiAbs{
    visibility: hidden;
}
briantjacobs commented 7 years ago

Yeah that makes sense as a responsible way to apply an override for a particular export. But a few times I've run into cases where less css-savvy folks are making edits to an export and unaware that their changes are inadvertently affecting other graphics on a page. Better protected default styles would help protect people from themselves.

mbloch commented 7 years ago

Ok, I'm convinced, I'll adopt your second suggestion v. soon.