Skip to content

Commit

Permalink
Merge pull request #1577 from dedis/work-fe1-dmassonn-fix-long-chirp-…
Browse files Browse the repository at this point in the history
…overflowing

Fix long chirps being cut off scren
  • Loading branch information
dayan9265 authored May 30, 2023
2 parents dcd5a6b + 22362f1 commit b3daf02
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fe1-web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ import { Color } from 'core/styles';
import { configureFeatures } from 'features';

import cameraPolyfill from './core/platform/camera/web-polyfill';
import wordBreakPolyfill from './core/platform/cssStyle/WordBreakPolyfill';

// load polyfill when the app loads
cameraPolyfill();

// This ensures that long words are broken correctly
wordBreakPolyfill();

const { messageRegistry, keyPairRegistry, navigationOpts, context } = configureFeatures();
configureKeyPair();
configureNetwork(messageRegistry, keyPairRegistry);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Replaces the polyfill
export default () => {};
15 changes: 15 additions & 0 deletions fe1-web/src/core/platform/cssStyle/WordBreakPolyfill.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Platform } from 'react-native';

/**
* This polyfill is required to make sure that long words are broken for chirps
* This is done by adding a css style to the head of the document
*/
export default () => {
if (Platform.OS !== 'web' || typeof 'navigator' === undefined) {
return;
}

const style = document.createElement('style');
style.textContent = '* {word-break: break-word;}';
document.head.append(style);
};
2 changes: 2 additions & 0 deletions fe1-web/src/features/social/components/ChirpCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ const ChirpCard = ({ chirp, isFirstItem, isLastItem }: IPropTypes) => {
'👍': !isConnected || !currentUserPopTokenPublicKey,
'👎': !isConnected || !currentUserPopTokenPublicKey,
'❤️': !isConnected || !currentUserPopTokenPublicKey,
delete: !isConnected || !currentUserPopTokenPublicKey,
};
const addReaction = (reaction_codepoint: string) => {
requestAddReaction(reaction_codepoint, chirp.id, laoId).catch((err) => {
Expand Down Expand Up @@ -264,6 +265,7 @@ const ChirpCard = ({ chirp, isFirstItem, isLastItem }: IPropTypes) => {
name="delete"
testID="delete_chirp"
onPress={() => setShowDeleteConfirmation(true)}
disabled={reactionsDisabled.delete}
size="small"
buttonStyle="secondary"
toolbar
Expand Down

0 comments on commit b3daf02

Please sign in to comment.