Skip to content

Commit

Permalink
Fix warnings after upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuswilms committed Aug 22, 2019
1 parent 41758a6 commit 02d109e
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 76 deletions.
4 changes: 2 additions & 2 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function App(props) {
})
}
});
}, []);
}, [props.router]);

function loadTree() {
Client.tree().then((data) => {
Expand Down Expand Up @@ -90,7 +90,7 @@ function App(props) {
// Use frontend configuration to configure app, if present.
useEffect(() => {
Client.configuration().then(setFrontendConfig, () => null)
}, []);
}, [setFrontendConfig]);

// Initialize tree navigation and title.
useEffect(loadTree, []);
Expand Down
6 changes: 1 addition & 5 deletions frontend/src/ColorGroup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,13 @@ function ColorGroup(props) {
const [colors, setColors] = useState([]);

useEffect(() => {
getData();
}, [props.src]);

function getData() {
if (props.src) {
// FIXME: This should obviously be derived from the src attribute
Client.get(`/The-Frontend/Documentation-Components/Color-Card-and-Color-Group${props.src.slice(1)}`).then(data => {
setColors(data.colors);
});
}
}
}, [props.src]);

let classes = ['color-group'];

Expand Down
17 changes: 11 additions & 6 deletions frontend/src/Doc/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,23 @@ import FigmaEmbed from '../FigmaEmbed';
import TypographySpecimen from '../TypographySpecimen';

function Doc(props) {
if (!props.htmlContent) {
return <div className="doc">{props.children}</div>;
}

useEffect(() => {
if (!props.htmlContent) {
return;
}
// window.requestAnimationFrame should ensure that the rendering
// has finished
// has finished.
window.requestAnimationFrame(() => {
if (props.onRender) { props.onRender() };
if (props.onRender) {
props.onRender()
};
});
});

if (!props.htmlContent) {
return <div className="doc">{props.children}</div>;
}

// Allow to use this inside the `transforms` constant. We cannot use
// `props.title` there as that refers to the component/element that is being
// transformed. The title is needed as to calculate the `Heading`'s jump
Expand Down
86 changes: 42 additions & 44 deletions frontend/src/FigmaEmbed/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,52 +14,50 @@ function FigmaEmbed(props) {
const [errorMessage, setErrorMessage] = useState(null);
const [loadingMessage, setLoadingMessage] = useState(null);

// Retrieves document.
useEffect(() => {
getDocument();
}, [props.document, props.frame]);

function getDocument() {
if (props.document && props.token) {
const myHeaders = new Headers();
myHeaders.append('X-Figma-Token', props.token);

setLoadingMessage('Loading document …');

fetch(`https://api.figma.com/v1/files/${props.document}`, {
method: 'GET',
headers: myHeaders,
})
.then(response => {
if (response.status === 200) {
return response.json();
} else {
setErrorMessage('Something went wrong.');
}
})
.then(data => {
findId(data);
})
.catch(err => {
console.log(err);
setErrorMessage('Something went wrong.');
});

// fetch(`https://api.figma.com/v1/teams/669136806690498635/styles`, {
// method: 'GET',
// headers: myHeaders,
// }).then((response) => {
// if (response.status === 200) {
// return response.json();
// } else {
// throw new Error('Something went wrong on api server!');
// }
// }).then((data) => {
// console.log(data)
// }).catch((err) => {
// console.log(err);
// });
if (!props.document || !props.token) {
return;
}
}
const myHeaders = new Headers();
myHeaders.append('X-Figma-Token', props.token);

setLoadingMessage('Loading document …');

fetch(`https://api.figma.com/v1/files/${props.document}`, {
method: 'GET',
headers: myHeaders,
})
.then(response => {
if (response.status === 200) {
return response.json();
} else {
setErrorMessage('Something went wrong.');
}
})
.then(data => {
findId(data);
})
.catch(err => {
console.log(err);
setErrorMessage('Something went wrong.');
});

// fetch(`https://api.figma.com/v1/teams/669136806690498635/styles`, {
// method: 'GET',
// headers: myHeaders,
// }).then((response) => {
// if (response.status === 200) {
// return response.json();
// } else {
// throw new Error('Something went wrong on api server!');
// }
// }).then((data) => {
// console.log(data)
// }).catch((err) => {
// console.log(err);
// });
}, [props.document, props.frame, props.token]);

function findId(data) {
let nameWeAreLookingFor = props.frame;
Expand Down
6 changes: 1 addition & 5 deletions frontend/src/NodeList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,12 @@ function Node(props) {
const [data, setData] = useState(null);

useEffect(() => {
getData();
}, [props.url]);

function getData() {
if (props.url) {
Client.get(props.url).then(data => {
setData(data);
});
}
}
}, [props.url]);

return (
<BaseLink router={props.router} routeName="node" routeParams={{ node: `${props.url}` }} className="node-list__node">
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Page/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function Page(props) {
}

document.title = title;
}, [props.title, props.designSystemTitle]);
}, [props.title, props.designSystemTitle, props.url]);

function docDidRender() {
// Check if there is a section marker in the URL, and if their is
Expand Down
10 changes: 2 additions & 8 deletions frontend/src/SourceView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,12 @@ function SourceView(props) {
Client.hello().then(data => {
setSource(data);
});
return;
}
getSource();
}, [props.url]);

function getSource() {
if (props.url !== undefined) {
} else if (props.url !== undefined) {
Client.get(props.url).then(data => {
setSource(data);
});
}
}
}, [props.url]);

let title = `API Response for /api/v2/tree/${props.url}`;

Expand Down
6 changes: 1 addition & 5 deletions frontend/src/TypographySpecimen/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,13 @@ function TypographySpecimen(props) {
// ];

useEffect(() => {
getData();
}, [props.src]);

function getData() {
if (props.src) {
// FIXME: This should obviously be derived from the src attribute
Client.get(`/The-Frontend/Documentation-Components/Typography-Specimen${props.src.slice(1)}`).then(data => {
setStyles(data.styles);
});
}
}
}, [props.src]);

return (
<div className="typography-specimen">
Expand Down

0 comments on commit 02d109e

Please sign in to comment.