Skip to content

added feature to add prefix in classes from setting tab #30

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

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
1 change: 1 addition & 0 deletions ads.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
google.com, pub-5619570488602254, DIRECT, f08c47fec0942fa0
12 changes: 12 additions & 0 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ module.exports = {
},
},
`gatsby-transformer-sharp`,
{
resolve: `gatsby-plugin-google-gtag`,
options: {
trackingIds: [
"G-H96HXS3WCV", // Replace with your Google Analytics tracking ID
],
pluginConfig: {
head: true,
sendPageView: true // set send_page_view to true
},
},
},
`gatsby-plugin-sharp`,
{
resolve: `gatsby-plugin-manifest`,
Expand Down
112 changes: 72 additions & 40 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"csslint": "^1.0.5",
"gatsby": "^2.20.12",
"gatsby-image": "^2.3.1",
"gatsby-plugin-google-gtag": "^5.7.0",
"gatsby-plugin-manifest": "^2.3.3",
"gatsby-plugin-offline": "^3.1.2",
"gatsby-plugin-postcss": "^2.2.2",
Expand All @@ -36,7 +37,7 @@
],
"license": "MIT",
"scripts": {
"build": "gatsby build",
"build": "export NODE_OPTIONS=--openssl-legacy-provider; gatsby build",
"develop": "gatsby develop",
"format": "prettier --write \"**/*.{js,jsx,json,md}\"",
"start": "npm run develop",
Expand Down
Binary file modified public/icons/icon-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/icons/icon-256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/icons/icon-384x384.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/icons/icon-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/page-data/dev-404-page/page-data.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"componentChunkName":"component---cache-dev-404-page-js","path":"/dev-404-page/","result":{"data":{"allSitePage":{"nodes":[{"path":"/404/"},{"path":"/"},{"path":"/page-2/"},{"path":"/404.html"}]}},"pageContext":{}}}
{"componentChunkName":"component---cache-dev-404-page-js","path":"/dev-404-page/","result":{"data":{"allSitePage":{"nodes":[{"path":"/404/"},{"path":"/"},{"path":"/page-2/"},{"path":"/404.html"},{"path":"/privacy-policy/"}]}},"pageContext":{}}}
4 changes: 4 additions & 0 deletions src/components/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ const Editor = ({ setCssTree, setEditorErrors }) => {
setEditorErrors,
editor.state.lint.marked.length > 0
);
typeof window !== "undefined" && window.gtag("event", "conversion_tracking", {
event_category: "data_update",
event_label: "editor_update",
})
// setCssTree(parse(value));
// setEditorErrors(editor.state.lint.marked.length > 0);
// console.log(editor, data, parse(value));
Expand Down
2 changes: 1 addition & 1 deletion src/components/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Img from "gatsby-image"
const Image = () => {
const data = useStaticQuery(graphql`
query {
placeholderImage: file(relativePath: { eq: "gatsby-astronaut.png" }) {
placeholderImage: file(relativePath: { eq: "" }) {
childImageSharp {
fluid(maxWidth: 300) {
...GatsbyImageSharpFluid
Expand Down
7 changes: 6 additions & 1 deletion src/components/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@ import TailwindBlock from './tailwind-block';

const Output = ({ settings, cssTree, editorErrors }) => {
const parseStyleTree = (styleTree, selector) => {
const tailWindStyles = [];
let tailWindStyles = [];
const errors = [];
const isHover = selector.indexOf(':hover') !== -1;
for (let i = 0; i < styleTree.length; i++) {
const property = styleTree[i];
const value = styleTree[property];
convertCss(property, value, tailWindStyles, errors, settings);
}
if(settings.classPrefix != ''){
tailWindStyles = tailWindStyles.map(element => {
return settings.classPrefix+'-'+element
})
}
Comment on lines +16 to +20
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fairly small points, I'll leave it up to you if you want to address them or not.
you may to use !== over != for strict equality
You may also want to consider updating the spacing on the if statements and add semicolons to match the set convention.

if (settings.classPrefix !== '') {
    tailWindStyles = tailWindStyles.map(element => {
        return settings.classPrefix + '-' + element;
    });
}

return [tailWindStyles, errors];
};
console.log(cssTree);
Expand Down
16 changes: 16 additions & 0 deletions src/components/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,22 @@ const Settings = ({ settings, setSettings }) => {
max="300"
></input>
</div>
<div className="w-full flex justify-between text-sm my-2 items-center">
<label>Prefix</label>
<input
value={settings.classPrefix}
onChange={(event) =>
handleChange(
'classPrefix',
event.target.value
)
}
className="rounded border border-teal-800 border-solid"
type="text"
id="remConversion"
name="remConversion"
></input>
</div>
<div className="w-full flex justify-between text-sm my-2 items-center">
<label>Auto Convert Margin/Padding</label>
<input
Expand Down
1 change: 1 addition & 0 deletions src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const IndexPage = () => {
remConversion: 16,
autoConvertSpacing: true,
autoConvertColor: true,
classPrefix:''
});
return (
<div
Expand Down
134 changes: 134 additions & 0 deletions src/pages/privacy-policy.js

Large diffs are not rendered by default.

29 changes: 28 additions & 1 deletion src/scripts/parser/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,34 @@ export const convertCss = (
`${TailWindMap[processedProperty][processedValue].substring(1)}`
);
} else {
errors.push(`${property}: ${value};`);
if(TailWindMap[processedProperty] && processedValue.split(' ').length === 1 && (TailWindMap[processedProperty][0] !== undefined)){
tailWindStyles.push(
`${(TailWindMap[processedProperty][0].split('-')[0]+'-['+processedValue+']').substring(1)}`
);
}else if(TailWindMap[processedProperty] && processedValue.split(' ').length === 2 && (TailWindMap[processedProperty][0] !== undefined)){
tailWindStyles.push(
`${(TailWindMap[processedProperty][0].split('-')[0]+'y-['+processedValue.split(' ')[0]+']').substring(1)}`
);
tailWindStyles.push(
`${(TailWindMap[processedProperty][0].split('-')[0]+'x-['+processedValue.split(' ')[1]+']').substring(1)}`
);
}else if(TailWindMap[processedProperty] && processedValue.split(' ').length === 4 && (TailWindMap[processedProperty][0] !== undefined)){
tailWindStyles.push(
`${(TailWindMap[processedProperty][0].split('-')[0]+'t-['+processedValue.split(' ')[0]+']').substring(1)}`
);
tailWindStyles.push(
`${(TailWindMap[processedProperty][0].split('-')[0]+'r-['+processedValue.split(' ')[1]+']').substring(1)}`
);
tailWindStyles.push(
`${(TailWindMap[processedProperty][0].split('-')[0]+'b-['+processedValue.split(' ')[2]+']').substring(1)}`
);
tailWindStyles.push(
`${(TailWindMap[processedProperty][0].split('-')[0]+'l-['+processedValue.split(' ')[3]+']').substring(1)}`
);
}
else{
errors.push(`${property}: ${value};`);
}
}
};

Expand Down
1 change: 1 addition & 0 deletions static/ads.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
google.com, pub-5619570488602254, DIRECT, f08c47fec0942fa0